On Sat, 01 Jun 2002 11:58:38 +0200 Claire Forchheimer <[EMAIL PROTECTED]> wrote:
I know the answer to the first part at least. I think you want to use two columns in the order by clause, and leave out the group by clause. As in: select * from tbl order by apt, name; I'm afraid its too late at night for me to be able to think about the rest. I'm sure it can be done though. Philip > 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??? -- Philip Spradling Unemployed C/C++/Java/SQL programmer (Who do you know who could use an experienced, talented but overeducated programmer?) [EMAIL PROTECTED] http:[EMAIL PROTECTED]/ --------------------------------------------------------------------- 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