Answer the question
In order to leave comments, you need to log in
SQL - sorting?
There is a table, for example, with the following structure:
CREATE TABLE mytable (
`id` int(8),
`name` varchar(64),
`group` varchar(16)
);
and records:
1|name1|group1
2|name2|group2
3|name3|group3
4|name4|group2
5|name5|group2
6|name6|group1
How to select all records and sort them by group field so that records with group2 were at the beginning in the presence of the ORDER BY `name` condition?
That is, as a result for a specific example, you will need to get
2|name2|group2
4|name4|group2
5|name5|group2
1|name1|group1
3|name3|group3
6|name6|group1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question