I’m using MySQL, and I want to sort a record or I want to group a record then sort it again by another condition like for example I have 6 items,
Names Group
Jack G1
Dian G2
Emily G2
Dean G1
Teddy G2
Gabe G1
So I want to sort this by group in alphabetized orby by name. Like,
Dean G1
Gabe G1
Jack G1
Dian G2
Emily G2
Teddy G2
So my problem is, how can I sort like this in MySQL?
Thanks.
So you want to order by one column first and then another? You can specify more than one column in the
ORDER BYclause of a query – separate them by commas, and the first one will be the ‘major’ sort, then subsequent columns in the list will be sorted within that.