桌子:
id 值
100 1
101 1
102 1
102 0
103 1
我希望选择返回 id 的 100,101,103;也就是说,如果同一个 id 有两行,一行 value=1,第二行 value=0,我想排除它。
感谢任何帮助。
尝试这个:-
Select id From table Group By id Having count(*) = 1
尝试这个:
SELECT * FROM
table
GROUP BY id
HAVING COUNT(*) = 1
可以使用having
MySQL 构造:
SELECT id, count(*) AS tehCount FROM table GROUP BY id HAVING tehCount = 1;