Reply
ORDER BY desc/asc issue
Old 08-06-2008, 08:18 PM ORDER BY desc/asc issue
Extreme Talker

Posts: 158
Trades: 0
Ok, so I have 5 rows, with a day column and a day set to each row.

it has...10,11,13,20, and 7 in no particular order.


if I do a query on that data, and do

Code:
ORDER BY day DESC
it outputs like this...
7
20
13
11
10

and if I do..
Code:
ORDER BY day ASC
the output looks like...

10
11
13
20
7

I don't want to have to put a leading 0 on 1-9...what can I do to make this work?
kbfirebreather is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 08-06-2008, 09:14 PM Re: ORDER BY desc/asc issue
JeremyMiller's Avatar
Full-Time TeraTasker

Posts: 1,470
Name: Jeremy Miller
Location: Marianna, FL
Trades: 0
Sounds like you have the field as a string instead of a number. Check that out. If you're not doing it, then each field type should be chosen for the data that's in there. Some people just make every field a VARCHAR instead of choosing things correctly and then they get errors. (Not saying that that's you, but for those who do do this, then they need to know.)

BTW: Database questions are best asked in the database forum.
__________________
Jeremy Miller - TeraTask
Content Farmer - Automated Posting for Content & Blog Sites
JeremyMiller is online now
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 08-06-2008, 09:18 PM Re: ORDER BY desc/asc issue
Extreme Talker

Posts: 158
Trades: 0
"BTW: Database questions are best asked in the database forum."

thanks for letting me know, I'm always confused cause of using php with the sql :-x

but regardless...I checked it out, and it was set to text...cause I think I originally was gonna spell out the day with that field, but am now using it as the calendar day of the month.

Before knowing this I decided to have a genius idea of using date(z) to get the day of the year (aug 6th is like..210 or something), and in my query, order by dayYear DESC, year DESC, and that took care of it.

Thanks for the input though...if I hadn't done that, I'm positive your solution would have worked.
kbfirebreather is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ORDER BY desc/asc issue
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.22033 seconds with 13 queries