我有EMP表,其中包含以下列:
EmpID
firstName
LastName
Age
DOB
status
如何让所有员工使用相同的FirstName和LastName
答案 0 :(得分:0)
这取决于您希望输出看起来像什么
SELECT firstName, lastName, count(*)
FROM emp
GROUP BY firstName, lastName
HAVING COUNT(*) > 1
将显示所有重复的firstName和lastName对。如果要获取两个重复行的empID(假设firstName和lastName都不能为NULL)
SELECT a.empID, b.empID
FROM emp a,
emp b
WHERE a.firstName = b.firstName
AND a.lastName = b.lastName
AND a.rowid > b.rowid