|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 1100 Hubert * 1200 Amos * 1200 Huber 1200 Aran 1200 Marks [/quote] 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. |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Order by, comparisons allowed? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|