★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum4/HTML/000185.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  MySQL
  Order by, comparisons allowed?

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Order by, comparisons allowed?
Jimmy
Junior Member
posted December 04, 1999 05:21 AM     Click Here to See the Profile for Jimmy   Click Here to Email Jimmy     Edit/Delete Message Reply w/Quote
A simple example:
I have a table Flats which includes the column Postal Code. In another table Users there is a column "mainflat" which has the ID of the Flat where the user is mainly living.
Now I would like to have an output sorted by postal code but Flats which are mentioned in the table Users as mainflats shall have a priority.
Like this output:
code:

(Mainflat) Postalcode Name
* 1100 Aran
* 1100 Vincent
1100 Hubert
* 1200 Amos
* 1200 Huber
1200 Aran
1200 Marks


The mainflat column shouldnt be shown. It has the ID of the mainflat. I just showed it for a better overall view.
A select statement like:

SELECT Flats.postcode,Users.name FROM Flats,Users WHERE Flats.usersID=Users.ID ORDER BY Flats.postcode, (Flats.ID=Users.mainflatID), Users.name;

doesn't work.
It is just the comparison which is wrong. Are there any functions I could use instead?
Thanks for any help,
Jimmy.

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.