I think you may be looking for function FIELD — while normally thought of as a string function, it works fine for numbers, too!
ORDER BY FIELD(field_name, 3,2,5,7,8,1)
More Related Contents:
- Laravel – only a zero is saved to the database
- storing user_id in session variable
- I am seeing this error on submitting form Error: query was empty [closed]
- mysqli or die, does it have to die?
- Convert from MySQL datetime to another format with PHP
- MySQL vs MySQLi when using PHP [closed]
- How do I set ORDER BY params using prepared PDO statement?
- Passing an array to a query using a WHERE clause
- How can I store and retrieve images from a MySQL database using PHP?
- PHP/MySQL Insert null values
- mysqli_stmt::bind_param(): Number of elements in type definition string doesn’t match number of bind variables
- PHP file cannot enter some part of code
- Laravel: PDOException: could not find driver
- Can you add an if statement in ORDER BY?
- PDO Connection Test
- Grouping WHERE clauses in Codeigniter
- Using if(isset($_POST[‘submit’])) to not display echo when script is open is not working
- MySQL (or PHP?) group results by field data
- SELECT COUNT() vs mysql_num_rows();
- Store procedures in phpMyAdmin
- Check if a row exists using old mysql_* API
- Unique IPs in a voting system
- MySQL get a random value between two values
- mysql – INSERT date range into date columns IF dates don’t overlap with existing ones
- php password_verify() hash and pass won’t match
- MySQL query using an array [duplicate]
- PHP mySQL – Insert new record into table with auto-increment on primary key
- Using MySQL’s TIMESTAMP vs storing timestamps directly
- How do I save PHP session data to a database instead of in the file system?
- Escaping SQL queries in Codeigniter