PHP MySQL Order by Two Columns
Here’s how to order your data by two or more columns using PHP and MySQL
Order by Two Columns
Here’s how to order by more than one column. When ordering by more than one column, the second column is only used if the values are identical with the onces in the first column:
SELECT column_name(s)
FROM table_name
ORDER BY column_name1, column_name2
Sort the display by Ascending or Descending Order
If you use the ORDER BY keyword, the sort-order of the recordset is ascending by default (1 before 9 and “a” before “p”).
Use the DESC keyword to specify a descending sort-order (9 before 1 and “p” before “a”):
SELECT column_name(s)
FROM table_name
ORDER BY column_name DESC
0 comments:
Post a Comment