1To get the sorted result from MySQL select statement we use order by clause with SELECT statement.
2
3Syntax:
4SELECT column_list FROM tablename ORDER BY column_name1 [ASC][DESC],column_name2 [ASC][DESC],...
1SELECT
2 select_list
3FROM
4 table_name
5ORDER BY
6 column1 [ASC|DESC],
7 column2 [ASC|DESC],
8 ...;
1SELECT * FROM mytable WHERE id IN (1,2,3,4) ORDER BY FIELD(id,3,2,1,4);
2
3# or
4SELECT * FROM mytable ORDER BY FIELD(field_name,'value1','vaue2','etc');