mysql order by issue

前端 未结 5 1031
后悔当初
后悔当初 2021-01-06 09:57

if i have a query like :

SELECT * FROM table  WHERE id IN (3,6,1,8,9);

this array of the ids is build in php dynamically , and the order is

5条回答
  •  别那么骄傲
    2021-01-06 10:16

    If you must do it this way you'll have to manipulate the data in PHP. MySQL can only order by natural orderings ascending or descending.

    Got to question though - why do you need the data returned in this very specific order? There may be an easier solution to your problem by re-jigging something further up in the code.

提交回复
热议问题