How to show records in same order where IDs are put into the IN() clause?

 
 
How to show records in same order where IDs are put into the IN() clause? 
 
 
1) SELECT id FROM table1 WHERE ... ORDER BY display_order, name

2) SELECT name, description, ... WHERE id IN ([id's from first])
 
The issue is that the second query does not return the results in the same order 
that the IDs are put into the IN() clause. 
 
Solution :- 

SELECT name, description, ...
FROM ...
WHERE id IN([ids, any order])
ORDER BY FIELD(id, [ids in order])

Comments

Popular posts from this blog

Changing the Java VM Memory Limits in Pentaho BI

utf8_general_ci VS utf8_unicode_ci what should we use?

CAS with Pentaho Community Edition