Query rows using Order by A, if A values are the same, Order by B as the second standard
问题 I want to query db rows using two standards: A first, B second. That is: Order by A, if A values are the same, Order by B as the second standard How to write the sql? Example: query table: id | A | B _ _ _ _ _ _ 1 | 1 | 1 _ _ _ _ _ _ 2 | 2 | 2 _ _ _ _ _ _ 3 | 2 | 1 _ _ _ _ _ _ 4 | 3 | 1 query result: id 1 3 2 4 回答1: Order by is used to sort the result from a table in ASC | DESC based on one or more column names. It sorts by ASC in default. Example: Select * from Table1 order by A, B In this