Jump to content

Archived

This topic is now archived and is closed to further replies.

karma_machine

mysql help

Recommended Posts

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

 

Example


George 21

Jim 18

Bob 21

Bill 16

George 12

 

and have this result

 


Bill 16

Bob 21

George 12

George 21

Jim 18

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.