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
  • 100,966
  • 191
  • 140
  • 197

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

jian
  • 4,119
  • 1
  • 17
  • 32