Grant,

Sure, anything's possible. Assuming you're table looks something like this:

CREATE TABLE people (
 id INT NOT NULL, 
 fname VARCHAR(15) NULL, 
 lname VARCHAR(20) NULL
) Type=InnoDB;

With data something like this:

INSERT INTO people (id, fname, lname) VALUES (1, 'John', 'Smith');
INSERT INTO people (id, fname, lname) VALUES (2, 'John', 'Smith');
INSERT INTO people (id, fname, lname) VALUES (3, 'Erika', 'Snow');
INSERT INTO people (id, fname, lname) VALUES (4, 'Michael', 'Boxer');
INSERT INTO people (id, fname, lname) VALUES (5, 'Julian', 'Baser');
INSERT INTO people (id, fname, lname) VALUES (6, 'Mary', 'McKnight');
INSERT INTO people (id, fname, lname) VALUES (7, 'Julian', 'Baser');

I would suggest a SQL statement like this to get the results you're looking
for.

SELECT COUNT(a.id), a.lname, a.fname
 FROM people AS a
 GROUP BY a.lname, a.fname
 HAVING COUNT(a.id) > 1;

You're selecting the information that's important to you (count, last name,
and first name). Grouping by first and last name. Then from that list, only
reviewing those with a count greater than 1. Presumably anything with a
count of 1 is unique in the table.

Regards,
Adam

-----Original Message-----
From: Grant Cooper [mailto:[EMAIL PROTECTED]
Sent: Friday, August 29, 2003 3:42 PM
To: [EMAIL PROTECTED]
Subject: listing all people who have the same firstname and lastname


I'm trying to get a query to work by listing all the people in a row with
the same last name and first name.

key, fname, lname
1 ,John, Smith
4, John, Smith
5, Cody,Edwards
2, Cody, Edwards

Don't list anyone that has a unique first name last name. Is this possible?
Trying to use the Count command.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to