Jump to content


Photo

mysql help


  • Please log in to reply
1 reply to this topic

#1 karma_machine

karma_machine
  • Members
  • Pip
  • Newbie
  • 3 posts
  • LocationNew Brunswick, Canada

Posted 23 August 2003 - 08:56 PM

i was wondering if there was a query that i could put in to sort thing first by name then by number.

Example
George 21Jim 18Bob 21Bill 16George 12

and have this result

Bill 16Bob 21George 12George 21Jim 18


#2 PHPcadet

PHPcadet
  • Members
  • PipPip
  • Member
  • 14 posts
  • LocationPlant City, Florida

Posted 23 August 2003 - 10:05 PM

With MySQL you can specify more than one column in the ORDER BY clause in your SELECT statement as in:
SELECT * FROM mytable ORDER BY name, number
You can even sort each column differently as in
SELECT * FROM mytable ORDER BY name ASC, number DESC
would give you :
Bill 16
Bob 21
George 21
George 12
Jim 18
If builders built buildings the way programmers write programs, then the first termite to come along would destroy civilization -- Anonymous




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users