Hi all,

I have a table including two colums: names and apartment numbers:

apt #| name
----------
    1 | Smith Joe
    1 | Smith Anne
    2 | Doe Richard
    3 | Svensen Mike
    3 | Brant Liza

I need to get a list in alphabetical order, but with people in the same
apt keept together:

Brant, Svensen
Doe
Smith, Smith

The difficulty is to get people living in the same apt grouped together.

SELECT * FROM tbl GROUP BY apt ORDER BY name  - will drop the second
name
found in each apt!

(The result would be this list:
Brant
Doe
Smith)

I've been banging my head black and blue over this query! Can anyone
help??!?


Two more issues in addition to this query is:

I'm using a PHP statement to find only the lastname in the name field,
can
this be done already in the query??

A nice feature would be to only list one name if both lastnames are the
same in one apt. In other words the list would then look like:

Brant, Svensen
Doe
Smith

can  this be done???





---------------------------------------------------------------------
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