1

I'm trying to delete from a table using where clause while passing it an array.

DELETE FROM Btemp
WHERE col2 =
    (SELECT ARRAY((SELECT col2 FROM Atemp INTERSECT SELECT col2 FROM Btemp)));

I'm getting this error:

ERROR:  operator does not exist: character varying = character varying[]
LINE 2: WHERE col2 =
                   ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883

And if do it without array, like below

DELETE FROM Btemp
WHERE col2 =
    (SELECT col2 FROM Atemp INTERSECT SELECT col2 FROM Btemp);

I get error:

ERROR:  more than one row returned by a subquery used as an expression

What should I do?

Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175

1 Answers1

0
DELETE FROM Btemp
WHERE col2 =
    ANY(SELECT col2 FROM Atemp INTERSECT SELECT col2 FROM Btemp);

further reference: IN vs ANY operator in PostgreSQL

Mark
  • 1,943
  • 7
  • 17