+------------+------------+
| student | department |
+------------+------------+
| 1234567890 | CS |
| 1234567890 | ME |
| 1234567890 | CS |
| 000000001 | ME |
+------------+------------+
如何获得相对于两个字段重复的行?
提前致谢。
最佳答案
SELECT student, department, count(*) as 'count'
FROM students
GROUP BY student, department
HAVING count > 1
+ ------------ + ------------ + ------- +
|学生|部门|计数|
+ ------------ + ------------ + ------- +
| 1234567890 | CS | 2 |
+ ------------ + ------------ + ------- +
关于sql - 在mysql中,如何找到相对于所有字段重复的行?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2057348/