Welcome to WebmasterWorld Guest from 18.206.16.123

Forum Moderators: open

Message Too Old, No Replies

Select query, order by question

     
4:46 pm on May 23, 2008 (gmt 0)

New User

10+ Year Member

joined:May 12, 2006
posts:21
votes: 0


I am trying to pull out some information from the database in user blocks of information, but I can't get it to order properly.

For example, if I have three columns in a table.. one for the date, one for a particular time, and one for the user name.. I am trying to get it to order like this:

Jun. 1/08 6:00 userONE
Jun. 1/08 7:00 userONE
Jun. 1/08 8:00 userONE
Jun. 1/08 9:00 userONE

Jun. 1/08 6:00 userTWO
Jun. 1/08 7:00 userTWO
Jun. 1/08 8:00 userTWO
Jun. 1/08 9:00 userTWO

Jun. 2/08 6:00 userONE
Jun. 2/08 7:00 userONE
Jun. 2/08 8:00 userONE
Jun. 2/08 9:00 userONE

Jun. 2/08 6:00 userTWO
Jun. 2/08 7:00 userTWO
Jun. 2/08 8:00 userTWO
Jun. 2/08 9:00 userTWO

This is the closest I could get the query:
SELECT date, hours, username FROM table1 ORDER BY date, hours, username

However, this orders it like this:

Jun. 1/08 6:00 userONE
Jun. 1/08 6:00 userTWO
Jun. 1/08 7:00 userONE
Jun. 1/08 7:00 userTWO
Jun. 1/08 8:00 userONE
Jun. 1/08 8:00 userTWO
Jun. 1/08 9:00 userONE
Jun. 1/08 9:00 userTWO

Can anyone please give me a hint as to how to write the select query in order to display the data in the way above?

5:06 pm on May 23, 2008 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5847
votes: 193


SELECT date, hours, username
FROM table1
ORDER BY date, username, hours
5:29 pm on May 23, 2008 (gmt 0)

New User

10+ Year Member

joined:May 12, 2006
posts:21
votes: 0


Wow! :) I guess I've been stareing into the screen for too long.

Thanks LifeinAsia!

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members