Is it possible to make a mysql query returning values without default order.for example am using the below query
select id_product,name from sample where id_product in ('675','123','745','954').
but it giving the output rows order by id_product.
OUTPUT:
id_product,Name
123 ,abc
675 ,xzy
745 ,bsh
954 ,dsh
I want the result should come like this, without default order.
id_product,Name
675 ,xzy
123 ,abc
745 ,bsh
954 ,dsh
any help would be appreciated.
解决方案
I suggest adding a Sort column in the database to force a custom order. Anyway, you can use a little trick using the FIND_IN_SET function:
SELECT id_product, name
FROM sample
WHERE id_product IN (675,123,745,954)
ORDER BY FIND_IN_SET(id_product, '675,123,745,954')