SQL:从2列中筛选2个匹配条件的数据

时间:2018-09-05 16:56:09

标签: mysql

我有一张这样的桌子

test_result

如何获得仅在数学上不及格的学生姓名?

1 个答案:

答案 0 :(得分:0)

尝试一下:

SELECT * 
from mytable 
where subject = 'math' and result = 'fail' AND name NOT IN (
   select name from mytable where subject != 'math' AND result = 'fail'
)