Home > database >  how to get data on arrays of values
how to get data on arrays of values

Time:05-28

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,
);

CodePudding user response:

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[]))
  • Related