永发信息网

使用SQL语句如何查询一个表中一个字段的值相同,另外一个字段的值不同?急!

答案:2  悬赏:80  手机版
解决时间 2021-03-11 18:34
  • 提问者网友:wodetian
  • 2021-03-10 18:23
使用SQL语句如何查询一个表中一个字段的值相同,另外一个字段的值不同?急!
最佳答案
  • 五星知识达人网友:西风乍起
  • 2021-03-10 19:00
if object_id('table1') is not null
begin
drop table table1
end
go
create table table1 (a int ,b int)
go
insert into table1
select 1,1
union
select 1,2
union
select 1,3
union
select 2,1
go
SELECT a.* from table1 a where exists(select * from table1 b where a.a=b.a and a.b<>b.b
)
--记得及时采纳,今天任务还没完成,只差一个了
全部回答
  • 1楼网友:慢性怪人
  • 2021-03-10 19:39
sqlserver 写法: update tablea set a=case len(a) when 1 then '00000'+a when 2 then '0000'+a when 3 then '000'+a when 4 then '00'+a when 5 then '0'+a end oracle写法: update talbea set a=case length(a) when 1 then '00000'||a when 2 then '0000'||a when 3 then '000'||a when 4 then '00'||a when 5 then '0'||a end
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯