I need to alter a table in my DB. What I want is to ad a column with type integer[] and add values to this column directly from another query which result is 4 id numbers.
What I got currently:
ALTER TABLE resourcen add rs_insurance integer[]
update resourcen set rs_insurance = (select li_id from li_versicherungsart)
The second command returns following error :
ERROR: column "rs_insurance" is of type integer[] but expression is of type integer
SQL state: 42804
Hint: You will need to rewrite or cast the expression.
Character: 37
How can I cast all IDs found to fit into int[] array?
select array_agg(li_id) ...but you most definitely need some kind of co-related subquery. But it's hard to tell without more detailed information on those two tables and how they relate to each other