WHERE ID = 20 OR ID = 2 OR ID = 4 OR ID = 5 OR ID = 23 OR ID = 14 OR ID = 15 OR ID = 16 OR ID = 28 OR ID = 37 OR ID = 25 OR ID = 22 OR ID = 21 ORDER BY NULL
but, alas, it gets sorted smallest number to largest... suggestions to make it stop sorting it? help!
Just so you know, your expression can be simplified using the IN() operator.
[text]WHERE ID = 20 OR ID = 2 OR ID = 4 OR ID = 5 OR ID = 23 OR ID = 14 OR ID = 15 OR ID = 16 OR ID = 28 OR ID = 37 OR ID = 25 OR ID = 22 OR ID = 21[/text]
You can either have it sorted by some criteria or it will be returned by the order it's found in the table. The results have to appear in some order, even if it's the actual order of the rows in the database.
maybe if you explained what's the problem with the order of the rows, someone would suggest an appropriate solution. Perhaps what you are looking for is ORDER BY RAND() ?
cardi777 wrote:is the ORDER BY FIELD feature unique to mysql ?
field() is built-in function that seems to be unique to mysql, yes. You could convert it into CASE ID WHEN 20 THEN 1 WHEN 2 THEN 2 WHEN 4 THAN 3 [....] ELSE 0 which would be more portable.