Topic: mySQL IN statement and order
$arr=array(5,7,2,3,1);
$implode=implode(",",$arr);
$result=$db->query('SELECT myinfo FROM mytable WHERE id IN(".$implode.")");
while($sub=$db->fetch_assoc($result)){
//spit out the information
}
Using the IN syntax in mysql I'm able to extract data based on an array. The problem is that the database is ordering the information from the database as 1,2,3,5,7 rather than the order it appears originally. What could I do to force mysql to order the information in the same order as the array?
On a side note, why is IN() rarely mentioned in any mysql documentation?
~~Creaturecorp