suchen

Heim  >  Fragen und Antworten  >  Hauptteil

mysql - sql中能否按id指定顺序取出数据?

id: 3,2,5,10,4

select * from id in (3,2,5,10,4);

但是顺序会乱。sql中有没有自带的处理函数?

------------------补充------------------------------

想利用mysql中limit做分页,所以想在mysql中原生解决。

阿神阿神2768 Tage vor644

Antworte allen(3)Ich werde antworten

  • PHP中文网

    PHP中文网2017-04-17 16:20:14

    SELECT * FROM user_info_tbl where id in (150633922,150986697,7000084,7000083) order by find_in_set(id,'150633922,150986697,7000084,7000083');

    Antwort
    0
  • 阿神

    阿神2017-04-17 16:20:14

    select *from table where id in (3,2,5,10,4) order by FIND_IN_SET(id,'3,2,5,10,4');

    Antwort
    0
  • 迷茫

    迷茫2017-04-17 16:20:14

    Select Id From Uid Where Id!='' Order By FleId(Id,2,3,1);

    Antwort
    0
  • StornierenAntwort