December 4th, 1999, 07:21 AM
Time spent in forums:
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:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
(Mainflat) Postalcode Name
* 1100 Aran
* 1100 Vincent
* 1200 Amos
* 1200 Huber
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;
It is just the comparison which is wrong. Are there any functions I could use instead?
Thanks for any help,