mysql - Query rows using Order by A, if A values are the same, Order by B as the second standard -
i want query db rows using 2 standards: first, b second. is: order a, if values same, order b second standard how write sql? example: query table:
id | | b _ _ _ _ _ _ 1 | 1 | 1 _ _ _ _ _ _ 2 | 2 | 2 _ _ _ _ _ _ 3 | 2 | 1 _ _ _ _ _ _ 4 | 3 | 1
query result:
id 1 3 2 4
order used sort result table in asc | desc based on 1 or more column names. sorts asc in default.
example:
select * table1 order a, b
in example results table1 sorted in asc b. if has same values, results sorted b in asc
Comments
Post a Comment