Answer the question
In order to leave comments, you need to log in
How to output through IN values in order in SQL?
SELECT * FROM table WHERE id IN(1,7,2,8,3);
It is necessary that the lines are displayed in the order specified in the id:
1 line
7 line
2 line
8 line
3 line
Answer the question
In order to leave comments, you need to log in
SELECT * FROM table WHERE id IN(1,7,2,8,3) ORDER BY FIELD(id,1,7,2,8,3)
SELECT * FROM table WHERE id IN(1,7,2,8,3) ORDER BY id ASC;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question