PostgreSQL JOIN with array type with array elements order, how to implement?

前端 未结 4 1150
梦谈多话
梦谈多话 2020-12-02 13:04

I have two tables in database:

CREATE TABLE items(
 id SERIAL PRIMARY KEY,
 ... some other fields
);

This table contains come data row with

4条回答
  •  佛祖请我去吃肉
    2020-12-02 13:49

    SELECT t.*
    FROM unnest(ARRAY[1,2,3,2,3,5]) item_id
    LEFT JOIN items t on t.id=item_id
    

    The above query select items from items table with ids: 1,2,3,2,3,5 in that order.

提交回复
热议问题