SELECT * FROM table WHERE id IN (2,4,1,5,3) ORDER BY FIELD(id,2,4,1,5,3);
Source: http://imthi.com/blog/programming/mysql-order-by-field-custom-field-sorting.php
More Related Contents:
- How to find similar results and sort by similarity?
- Mysql: Select rows from a table that are not in another
- Sorting varchar field numerically in MySQL
- Mysql order by specific ID values
- MySQL: Sort GROUP_CONCAT values
- ORDER BY date and time BEFORE GROUP BY name in mysql
- updating columns with a sequence number mysql
- mysql sorting of version numbers
- is php sort better than mysql “order by”?
- ORDER BY alphabet first then follow by number
- Default sort-ordering in MySQL (ALTER TABLE … ORDER BY …;)
- Joining three tables using MySQL
- Strange duplicate behavior from GROUP_CONCAT of two LEFT JOINs of GROUP_BYs
- MySQL Orderby a number, Nulls last
- Troubleshooting “Illegal mix of collations” error in mysql
- How should I store GUID in MySQL tables?
- How to perform a mysqldump without a password prompt?
- Select the 3 most recent records where the values of one column are distinct
- Mysql count instances of substring, then order by
- How to remove leading and trailing whitespace in a MySQL field?
- How to reset the root password in MySQL 8.0.11?
- How does MySQL CASE work?
- What characters have to be escaped to prevent (My)SQL injections?
- How to save MySQL query output to excel or .txt file? [duplicate]
- MySQL: Set user variable from result of query
- Is there any performance gain in indexing a boolean field?
- NodeJS responded MySQL timezone is different when I fetch directly from MySQL
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ [duplicate]
- How to swap values of two rows in MySQL without violating unique constraint?
- MYSql config bind-address set to 0.0.0.0 but netstat shows different on Ubuntu