我不知道/分组?有?子查询?我可以使用什么?

时间:2017-01-13 05:56:23

标签: mysql join group-by having

select seq from a where link != 1 
seq | link
1   | 1
1   | 0
2   | 0
3   | 1
4   | 0

我希望不在1:2,4中返回seq

1 个答案:

答案 0 :(得分:0)

SELECT seq
  FROM a
 GROUP BY seq
HAVING SUM(link = 1) = 0;

SQL Fiddle