![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm sure this has been answered before, but the search seems to be down again. How can I convert the results of a subselect into an array? IE: CREATE TABLE a(a int, b int, c int[]); INSERT INTO table_a SELECT a, b, (SELECT c FROM table_c WHERE table_c.parent = table_b.id) FROM table_b |
#3
| |||
| |||
|
|
On Thu, Oct 28, 2004 at 05:37:29PM -0500, Jim C. Nasby wrote: I'm sure this has been answered before, but the search seems to be down again. How can I convert the results of a subselect into an array? IE: CREATE TABLE a(a int, b int, c int[]); INSERT INTO table_a SELECT a, b, (SELECT c FROM table_c WHERE table_c.parent = table_b.id) FROM table_b See the "Array Constructors" section in the PostgreSQL documentation: http://www.postgresql.org/docs/7.4/s...Y-CONSTRUCTORS INSERT INTO table_a SELECT a, b, ARRAY(SELECT c FROM table_c WHERE table_c.parent = table_b.id) FROM table_b -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings |
#4
| |||
| |||
|
|
Ok, next stupid question that I can't find in the docs... How would I join a table to an array? IE: if I have an array of primary keys for some table and I want to get the name field from that table and turn it back into an array, how would I do that? |
![]() |
| Thread Tools | |
| Display Modes | |
| |