I have a table with 5 columns. When I list the table, I want to order by one column so that the types are grouped together and then order them alphabetical so that they are easy to find.
Is it possible to ORDER
by two different columns?
Here is my current select:
$query_rs_cms = "SELECT * FROM games ORDER BY type ASC";
I guess what I'm looking for is something like:
SELECT *
FROM games
ORDER BY type THEN ORDER BY title ASC";
You can specify the ORDER BY by either the column name or by the column number of the return.
So you could do:
SELECT * FROM games ORDER BY Type, Title
Or something like:
SELECT Type, Title, Column1, Column2 FROM games ORDER BY 1, 2
You can also do ascending and descending. So if you wanted Type Descending but Title Ascending:
SELECT * FROM games ORDER BY Type DESC, Title ASC
SELECT * FROM games ORDER BY type, title
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With