Is there a way to iterate through an array in SQL not using stored procedures? For instance given:
a | b
--+------
a | {1,2}
I would like to flatten the array into individual rows as in:
a | b
--+---
a | 1
a | 2
Clarification: I am trying to do this in Postgres and am looking for a pure SQL solution as opposed to using stored procedures. Please correct me if I am wrong but I don't think this has been addressed in previous questions. Thanks!
Very simple
select a, unnest(b)
from t
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.