我需要为具有重复项的多部分标识符选择某些字段。
我有查询以正确获取重复项。
SELECT b.MemEmpID, b.LastName, b.FirstName
FROM table1 As b
GROUP BY b.MemEmpID, b.LastName, b.FirstName
HAVING Count(*) > 1
但是在找到重复项后,我需要从同一个表中获取更多信息,但仅限于具有重复项的多部分标识符。所以像下面这样。
有人可以帮我正确的语法吗?
SELECT a.memempid, a.depkey, a.lastname, a.firstname, a.birthdate, a.memrelation
FROM table1 As a
INNER JOIN(SELECT b.MemEmpID, b.LastName, b.FirstName
FROM table1 As b
GROUP BY b.MemEmpID, b.LastName, b.FirstName
HAVING Count(*) > 1)
ON b.memempid = a.memempid
AND b.lastname = a.lastname
AND b.firstname = a.firstname