Q:

PostgreSQL order of WHERE "table"."column" IN query

In PostgreSQL, does this query
SELECT "table".* FROM "table" WHERE "table"."column" IN (1, 5, 3)

always return the results in the 1, 5, 3 order or is it ambiguous?
If it's ambiguous, how do I properly assure the results are in the order 1, 5, 3?

A:

The WHERE clause will not order the results in any way, it will just select matching records, in whatever order the database index finds them in.
You'll have to add an order by clause.

A:

Add something like the following to your select statement
order by CASE WHEN "column"=1 THEN 1
              WHEN "column"=2 THEN 2
              ELSE 3
       END

if you have many more than three values it may be easier to make a lookup table and join to that in you query 

