Here's a simple but powerful MySQL thing. Sometimes when selecting records using a list of values in an IN() statement, you also want to order by that list. (If you've ever tried this, you know that the matches found via IN() are not returned in the same order as the values from you IN() list).

There are a lot of complex ways you could do this, but here's the simplest way I know, ordering the query results by the same list.

view plain print about
1<cfquery datasource="#request.dsn#" name="getstuff">
2 SELECT m.id, m.title
3 FROM mytable m
4 WHERE m.id IN(#request.getids#)
5 GROUP BY m.id
6 ORDER BY m.id IN(#request.getids#)
7 </cfquery>

The trick is the ORDER BY, using the same IN() statement as the IN() from the where clause.

That should do it.