Sorting in several columns in the same way:

First, the specified column is sorted, then the second, and so on. ORDER BY ..., ..., ...

There is a table:

enter image description here

Sort the query result in this way:

SELECT * FROM `dogs` ORDER BY NickName , Breed; 

The question of why I do this is:

enter image description here

First sorted by NickName, in the end Frolov will take the first place, but when it will be sorted by Breed, then Danyil should stand first than Nikita But, for some reason, Nikita is worth the first. Can you please tell me why?

  • one
    sorting by the second column is relevant for the same values ​​in the first column. otherwise there would be no point in the first column - Mike
  • Yes, it is logical .. Thank you so much - Sckoriy

0