sql - How can you expand a "condensed" PostgreSQL row into separate columns? -


i have function returns table.

if run select * some_function(12345) result is:

object_id | name ----------------     12345 | "b" 

if run select some_function(12345) result is:

some_function ------------- (12345,"b") 

the problem want original form (so can access individual column values), have argument some_function() come column in table. can execute select some_function(thing_id) things returns:

some_function ------------- (12345,"b") (12346,"c") (12347,"d") 

whereas want returned is:

object_id | name ----------------     12345 | "b"     12346 | "c"     12347 | "d" 

so how can 1 "unnest" or "expand" such condensed row?

in postgresql 9.3 or newer use implicit lateral query:

select f.* things t, some_function(t.thing_id) f; 

prior versions, causes multiple-evaluation of some_function:

select (some_function(thing_id)).* things; 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -