22,210
社区成员
发帖
与我相关
我的任务
分享
select * from tb_ks t where exists(
select 1 from tb_ks where name=t.name and (km='数学' or km='英文')
group by name having count(1)>1
)
select name from
(
SELECT distinct name FROM tb_KS WHERE km='数学'
union all
SELECT distinct name FROM tb_KS WHERE km='英文'
) t
group by name having count(*) = 2
--------------------------------------
select * from tb_ks where name in
(
select name from
(
SELECT distinct name FROM tb_KS WHERE km='数学'
union all
SELECT distinct name FROM tb_KS WHERE km='英文'
) t
group by name having count(*) = 2
)
select * from tb_ks where km ='数学' and name in(select name from tb_ks where km ='英文')