If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Need help with "order by"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-26-04, 04:10
jawbox jawbox is offline
Registered User
 
Join Date: Jan 2004
Posts: 1
Need help with "order by"

Hello,

i want to build up an database with results for my soccer-club.

I want to sort the results by date and then the league (because we have thre teams in three f´different leagues)

But when i do it with "order by date" then it works not correct:

Example:

25.01.2003 Team 1 vs. Team 2 4:2
23.12.2002 Team 1 vs. Team 4 5:1
22.01.2003 Team 1 vs Team 16 4:1

You know what i mean.

What have i to do that it works correct. Not only the first number of the date?

Thanks alot for your help.
Reply With Quote
  #2 (permalink)  
Old 01-26-04, 07:59
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
actually, i don't know what you mean

the sql you want is

... order by datefld, league

if it is sorting by the first number of the date, this suggests your date field is a character string and not a date field...
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-26-04, 10:53
bzakrzew bzakrzew is offline
Registered User
 
Join Date: Jan 2004
Location: Kennesaw, GA
Posts: 10
Or, what you could do is change the format of your date to be 2003.12.23 etc, and then even if the column type is a string/char, it will still sort correctly.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On