Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT name, json_array_elements(myjson)->>'id' id FROM
- (SELECT 'Dingsda'::text AS name, json_build_array('{"id" : 100}'::json, '{"id" : 200}'::json) myjson
- UNION ALL
- SELECT 'Dingsbums'::text AS name, json_build_array('{"id" : 101}'::json, '{"id" : 201}'::json, '{"id" : 301}'::json) myjson
- ) t;
- +-----------+-----+
- | name | id |
- +-----------+-----+
- | Dingsda | 100 |
- | Dingsda | 200 |
- | Dingsbums | 101 |
- | Dingsbums | 201 |
- +-----------+-----+
- +-----------+-----+-------+
- | name | id | index |
- +-----------+-----+-------+
- | Dingsda | 100 | 0 |
- | Dingsda | 200 | 1 |
- | Dingsbums | 101 | 0 |
- | Dingsbums | 201 | 1 |
- | Dingsbums | 301 | 2 |
- +-----------+-----+-------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement