库名
a b
a 0
a 1
b 0
c 1
d 0
d 1
需要查出同时有0和1 下a字段的值,我并不知道A表
结果是:
a 0
a 1
d 0
d 1
select *
from 表
where a in (select a
from 表
where b in (0, 1)
group by a
having count(distinct b) = 2)
where条件b=0 and b =1,group by 过滤有相同的值这样吗
select a from
(
select * from 表 a where b in (0,1)
)
having count(b)=2