On 6/30/05, M.D.G. Lange <mlange(at)dltmedia(dot)nl> wrote:
> Another option would be:
> SELECT * FROM table WHERE id=2003 OR id=1342 OR id=799 OR id=1450;
> This should give you the results in the right order...
I don't think so...
create temporary table seq as select * from generate_series(1,20) as g(id);
select * from seq where id in (5,2,12);
id
----
2
5
12
select * from seq where id = 5 or id = 2 or id = 12;
id
----
2
5
12
It certainly doesn't work.
You have to order it by something, like:
select * from seq where id in(5,2,12) order by id=5 desc,id=2 desc,id=12 desc;
id
----
5
2
12
Regards,
Dawid