Hi everyone,
I've run a simple select :
select * from ... order by col2, col1
The result is :
col1 col2 ...
4 1
2 1
7 1
5 2
7 2
8 2
8 3
As you can see, the lines are sorted by col2, but NOT but col1. Why ?
Thanks for your help,
Mark
MySQL ORDER BY problem...
Moderator: General Moderators
Igoy:igoy wrote:if you want to sorting order by col1, why are you using col2 in ORDER BY clause?
You can sort by more than one column.
For example, sorting by col2, then by col1. If the data in some data in col2 is duplicated, for example, if there were 3 people with the surname jones, MySQL would then order each of the people by col1, their firstname.
Mark53:
Not sure why you are having that problem Mark53, what are the data types of the 2 columns.
Mark