PostgreSQL unnest with empty array

前端 未结 5 1937
刺人心
刺人心 2021-02-12 23:23

I use postgreSQL 9.1. In my database there is a table which looks like

id | ... | values
-----------------------
1  | ... | {1,2,3}
2  | ... | {}
5条回答
  •  我在风中等你
    2021-02-12 23:52

    This works on Postgres 10 also:

    SELECT id, UNNEST(CASE WHEN "values" <> '{}' THEN "values" ELSE '{null}' END)
    

提交回复
热议问题