PostgreSQL: unwrap ARRAY into rows

Trabla: PostgreSQL: unwrap ARRAY into rows

Solving:

Use unnest funtion - expand an array to a set of rows

Official Docs: http://www.postgresql.org/docs/9.2/static/functions-array.html

Example:

SELECT  city 
FROM 
unnest( ARRAY[ 'New York', 'Tokyo', 'London' ]   )  AS city

Result:

city
text
-----
New York
-----
Tokyo
-----
London


No comments:

Post a Comment