SQLite Forum

select in order
Login
Another way, not any more practical than the others Gunter already provided, just for fun:

```
sqlite> create table p (id integer primary key, other);
sqlite> insert into p values (1, 'one'), (2, 'two'), (3, 'three'), (4, 'four');
sqlite> .mode col
sqlite> .header on
sqlite> select * from p; -- insert order (i.e. rowid PK)
id          other
----------  ----------
1           one
2           two
3           three
4           four
sqlite> select * from p where id in (3,2,4); -- arbitrary order returned
id          other
----------  ----------
2           two
3           three
4           four
sqlite> select * from p where id in (3,2,4)
   ...> order by case id when 3 then 1 when 2 then 2 when 4 then 3 end;
id          other
----------  ----------
3           three
2           two
4           four
sqlite>
```