我有包含以下列的 EMP 表:
EmpID
firstName
LastName
Age
DOB
status
如何获得具有相同名字和姓氏的所有员工
It depends what you want your output to look like
SELECT firstName, lastName, count(*)
FROM emp
GROUP BY firstName, lastName
HAVING COUNT(*) > 1
will show you all the firstName and lastName pairs that are duplicated. If you want to get the empID of both duplicated rows (assuming neither firstName nor lastName can be 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