SQL code/Query Question

GriffyNJ

Registered User.
Local time
Today, 10:59
Joined
Jul 16, 2008
Messages
28
I'm working on the following SQL for a query:

SELECT PERSON_NAME.Person_id, PERSON_NAME.delete, PERSON_NAME.Lastname_name_local1, PERSON_NAME.Person_name_id, PERSON_NAME.Middle_name, PERSON_NAME.Name_suffix
FROM PERSON_NAME
WHERE (((PERSON_NAME.person_id) In (SELECT [person_id] FROM [PERSON_NAME] As Tmp GROUP BY [person_id] HAVING Count(*)>1 )))
ORDER BY PERSON_NAME.Person_id;

I simply want to add to this code the ability to select not only person_id's that have a count greater that one, I want to select both person_id's AND lastname's that have a count greater than one. What should I do to improve the code?
 
Ok - not withstanding that normally you would expect that for a table of people - person_id would a primary key and therefore have no duplicates...

you could try concatinating person_id and lastname then checking for > 1
 
or you could query your query finding those records that match the id's you've pulled.
 

Users who are viewing this thread

Back
Top Bottom