Ordering by the order of values in a SQL IN() clause

前端 未结 13 962
旧巷少年郎
旧巷少年郎 2020-11-22 04:12

I am wondering if there is away (possibly a better way) to order by the order of the values in an IN() clause.

The problem is that I have 2 queries, one that gets al

13条回答
  •  难免孤独
    2020-11-22 04:44

    I think you should manage to store your data in a way that you will simply do a join and it will be perfect, so no hacks and complicated things going on.

    I have for instance a "Recently played" list of track ids, on SQLite i simply do:

    SELECT * FROM recently NATURAL JOIN tracks;
    

提交回复
热议问题