faqts : Computers : Databases : MySQL : Language and Syntax : Queries : Order By

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

42 of 50 people (84%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Can I order results from a MySQL query by two different columns?

May 14th, 2000 20:04
Nathan Wallace, Sam Masiello


You can do that by just adding the second column to your order by
statement at the end of your query.  Like this:

  SELECT a, b
  FROM table
  WHERE .....
  ORDER BY a, b ;

If you have more columns that you end up wanting to order by, just add
them to your order by list and separate the fields by commas.