我希望根据这些列从我的数据库表中获取重复的行:TaskID,StudentID,DateChanged
请让我知道如何查询这个。感谢
答案 0 :(得分:2)
试试这个
SELECT Taskid, Studentid, DateChangeid
FROM Table1
GROUP BY Taskid, studentid, datechangeid
HAVING COUNT(*) > 1
如果您想显示所有字段,请尝试此
SELECT *
FROM Table1 t
JOIN ( SELECT Taskid, Studentid, DateChangeid
FROM Table1
GROUP BY Taskid, studentid, datechangeid
HAVING COUNT(*) > 1) temp
ON t.taskid = temp.taskid AND t.studentid= temp.studentid AND t.datechangeid= temp.datechangeid
答案 1 :(得分:0)
根据您的描述,我认为这就是您所需要的:
SELECT *
FROM Table1
WHERE TASKID = 'TaskID1'
AND StudentId = 'StudentID1'
AND DateChanged = 'DateChanged1'