Say I have a table with an array column:
id | subIds
1 | {1,2,3}
2 | {4,5}
How would I return the resultset:
id | subId
1 | 1
1 | 2
1 | 3
2 | 4
2 | 5
... in a single query without using a function?
By "without using a function" I assume you mean "without writing my own function to do it".
The unnest() function will do what you want
select id, unnest(subids) as subid
from the_table;
The order on how the elements are returned is undefined though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With