Skip to content
Advertisement

SQL how to convert array to values for use in IN clause

Working in Postgres SQL:

My query argument comes in as a comma separated string: ‘ABC,BCD’

I am trying to construct the query below, but getting an error:

ERROR:

Operator does not exist: character varying = text[]

My question is how to convert ‘ABC,BCD’ to a list of values to use in the IN CLAUSE. Prefer answer in SQL query, not method or function. Thanks.

Advertisement

Answer

With an array, you need to use the ANY operator:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement