Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to get data on arrays of values

I have pairs of values test_name, test_surname.
How can I delete these rows from the table with one query. I assumed it could be done this way, but it can’t be done this way.

DELETE FROM test_info
WHERE id_name = ($1::uuid[])
  AND id_surname = ($2::uuid[])

this is schema

create table test_info
(
    id_name    uuid not null,
    id_surname uuid not null,
);

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Example of unnesting 2 arrays in one query (arrays must have the same size and dimension)

select unnest(array['1','2']),unnest(array['3','4']);

Delete rows

delete from test_info 
where 
 (id_name,id_surname) in (select unnest($1::uuid[]),unnest($2::uuid[]))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading