I've tested this on a table of mine with different names, so it should work when you 
tweak your columns/table.  The "having clause" is a seldom taught, but highly useful 
clause.

select count(1), first_name, last_name
from myuserstable
group by first_name, last_name
having count(1) > 1;

You should be able to get rid of the count(1) in the select list if you want.

For more information on select queries and the having clause you can look at this 
manual page:

http://www.mysql.com/doc/en/SELECT.html

Greg

SQL, query, duplicate, having clause

-----Original Message-----
From: Phillip S. Baker [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 16, 2002 2:17 PM
To: [EMAIL PROTECTED]
Subject: Query for multiple rows


Greetings all,

I have a users table in the DB.
I am importing allot of existing data from various places into this users 
table.
There is a strong likelihood of the same user getting entered twice.
Though each record will have a separate and unique ID, I want to be able to 
query the table and look for duplicate records based on first name last name.

So for clarity I want to execute a query to one table.
The results I want displayed are a listing of records that have the same 
first name and last name of other records in that same table.

Am I making this clear and what do I need to do?

Thanx

Fibilt

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to