E
E
Eugene2019-09-30 09:18:22
PostgreSQL
Eugene, 2019-09-30 09:18:22

How to update table via array?

There is a table example
table1(id, name, id_name).
There is an array array id_name[1,2,3]
As in the query
update table1 set
id = v_id,
name = v_name,
id_name = unnest(array)??????
It works in insert unnest, I can't figure out how it works in update. Thank you very much in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan., 2019-09-30
@EpOsS

To update a table, you need to somehow connect each row of the table being changed with an array (so that the relationship is one to one), i.e. in the array conditionally d.b. the key field (and the array must be two-dimensional) that you specify in the update request.
More details here:
https://postgrespro.ru/docs/postgrespro/9.5/querie...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question