On Fri, 29 Aug 2003 12:42:03 -0700
Grant Cooper <[EMAIL PROTECTED]> wrote:
> 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
SELECT fname,ln
Fortuno, Adam wrote:
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;
That's a great way of doing it if Grant doesn't need the IDs, which he
*did* have listed in
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 I