MySQL queries the in operation. The query results are displayed in the in set order: select * fromtestwhereidin (, 5) orderbyfind_in_set (id, 5); occasionally seen... Some people may have noticed this, but I have never known SQL: select * fromtablewhereidIN (,);
MySQL queries the in operation. The query results are displayed in the in set order: select * from test where id in (, 5) order by find_in_set (id, '3 '); occasionally seen... Some people may have noticed this, but I have never known SQL: select * from table where id IN (,);
MySQL queries the in operation. The query results are displayed in the in set order:
Select * from test where id in (3, 1, 5) order by find_in_set (id, '3, 1, 5 ');
Occasionally seen... Some people may have noticed it, but I did not know it before.
SQL: select * from table where id IN (3, 6, 9, 1, 2, 5, 8, 7 );
After such a situation is obtained, the IDs are actually sorted by 1, 2, 3, 4, 5, 6, 7, 8, 9, but what if we really want to sort IN order? Can SQL be completed? Do you need to get it back before foreach? In fact, mysql has this method.
SQL: select * from table where id IN (,) order by field (id );
The order is the specified order.