Sorting Question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Sorting Question

Post by fatal »

Hello, i was woundering if anyone knows if you can sort a query twice. Because my news script sorts by date, but then the problem arises what if i post twice in a day. What i want to do is to first sort by date then by time. Is that possible within one query? Thank you.
User avatar
Elmseeker
Forum Contributor
Posts: 132
Joined: Sun Dec 22, 2002 5:48 am
Location: Worcester, MA

Post by Elmseeker »

why not just put a unix time stamp into the DB ina field called...whatever you want I guess let's call it sortme for his example and then just ORDER by sortme DESC LIMIT 0,7
to show the last 7 entries in reverse order in which they were posted...
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Sorting Question

Post by fractalvibes »

Also bear in mind that you can sort on a number of fields....
If your table looked like:

ArticleID - int autonumber
ArticelText - varchar 255
PostDate - Date
PostTime - TimeStamp
......etc you could:

SELECT ArticleText
, ArticleID
.......etc
WHERE.....etc
ORDER By PostDate, PostTime


would do it also if you kept the date and time seperate...

Phil J.
User avatar
fatal
Forum Contributor
Posts: 118
Joined: Sat Apr 20, 2002 10:47 am
Location: East Coast

Post by fatal »

Thank you guys for all you ideas, and help!
Post Reply