Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Queries Order By multiple 1

Status
Not open for further replies.

je150

IS-IT--Management
Jun 10, 2003
33
0
0
US
I have a database of employee time logs and i have it already working perfectly and set to order by the date. Is there a way to not only order the output (a table with 6 fields) by the date but also by the username. Right now it comes out like this

Userid Date
name1 July 06 2004
name2 July 06 2004
name2 July 06 2004
name1 July 06 2004
name3 July 07 2004
name2 July 08 2004

And i want this

Userid Date
name1 July 06 2004
name1 July 06 2004
name2 July 06 2004
name2 July 06 2004
name1 July 07 2004
name2 July 08 2004

Here is the sql query i am using to display the data. If you need more code for a frame of reference tell me and ill post the whole thing.

Code:
$result = mysql_query("SELECT * FROM $dbtable ORDER BY date ASC",$authentication);
 
Code:
$result = mysql_query("SELECT * FROM $dbtable ORDER BY date ASC[b],Userid[/b]",$authentication);

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Thanks KarverR, never even though of that. I was trying to do an ORDER BY ??? AND ???. Anyway, it worked.

Code:
$result = mysql_query("SELECT * FROM $dbtable ORDER BY date ASC [COLOR=red],name[/color]",$authentication);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top