The query you want is this one
SELECT * FROM user
ORDER BY
IF(FIELD(user_id,1,4,5)=0,99999,FIELD(user_id,1,4,5)),user_name;
I loaded you sample data and ran the query in MySQL 5.5.12 in Windows
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 5.5.12 MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
MySQL (Current test) :: USE example
Database changed
MySQL (Current example) :: DROP TABLE IF EXISTS user;
user_name VARCHAR(20)
);
INSERT INTO user VALUES
(1,'Peter'),(2,'John'),
(3,'Luke'),(4,'Tim'),
(5,'George'),(6,'Michael');
SELECT * FROM user;
SELECT * FROM user
ORDER BY
IF(FIELD(user_id,1,4,5)=0,99999,FIELD(user_id,1,4,5)),user_name;
Query OK, 0 rows affected (0.02 sec)
MySQL (Current example) :: CREATE TABLE user
-> (
-> user_id INT,
-> user_name VARCHAR(20)
-> );
Query OK, 0 rows affected (0.08 sec)
MySQL (Current example) :: INSERT INTO user VALUES
-> (1,'Peter'),(2,'John'),
-> (3,'Luke'),(4,'Tim'),
-> (5,'George'),(6,'Michael');
Query OK, 6 rows affected (0.02 sec)
Records: 6 Duplicates: 0 Warnings: 0
MySQL (Current example) :: SELECT * FROM user;
+---------+-----------+
| user_id | user_name |
+---------+-----------+
| 1 | Peter |
| 2 | John |
| 3 | Luke |
| 4 | Tim |
| 5 | George |
| 6 | Michael |
+---------+-----------+
6 rows in set (0.00 sec)
MySQL (Current example) :: SELECT * FROM user
-> ORDER BY
-> IF(FIELD(user_id,1,4,5)=0,99999,FIELD(user_id,1,4,5)),user_name;
+---------+-----------+
| user_id | user_name |
+---------+-----------+
| 1 | Peter |
| 4 | Tim |
| 5 | George |
| 2 | John |
| 3 | Luke |
| 6 | Michael |
+---------+-----------+
6 rows in set (0.00 sec)
MySQL (Current example) ::
Give it a Try !!!
UPDATE 2011-07-26 13:37 EDT
If the order of the list matters, simply write the list as needed.
EXAMPLE : if you need the list ordered 4,1,5 then the query should look like this:
SELECT * FROM user
ORDER BY
IF(FIELD(user_id,4,1,5)=0,99999,FIELD(user_id,4,1,5)),user_name;
Here is the execution with the same sample data:
MySQL (Current example) :: SELECT * FROM user
-> ORDER BY
-> IF(FIELD(user_id,4,1,5)=0,99999,FIELD(user_id,4,1,5)),user_name;
+---------+-----------+
| user_id | user_name |
+---------+-----------+
| 4 | Tim |
| 1 | Peter |
| 5 | George |
| 2 | John |
| 3 | Luke |
| 6 | Michael |
+---------+-----------+
6 rows in set (0.00 sec)
MySQL (Current example) ::