MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 4th, 1999, 06:21 AM
Jimmy
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Order by, comparisons allowed?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT