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

如题所述

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
)
--记得及时采纳,今天任务还没完成,只差一个了
温馨提示:答案为网友推荐,仅供参考