Let's say I have this query and I'm using Golang to communicate
SELECT
u."id",
u."name",
u.accreditation
FROM
universities u
WHERE
u.accreditation ILIKE ANY ( $1 )
OR NOT u.accreditation ILIKE ANY ( '{A, B, C}' ) ;
The case is I want to make the query OR NOT u.accreditation ILIKE ANY ( '{A, B, C}' ) as a variable $2 like this
SELECT
u."id",
u."name",
u.accreditation
FROM
universities u
WHERE
u.accreditation ILIKE ANY ( $1 )
$2 ;
- If $1 contains "O" then $2 is
OR NOT u.accreditation ILIKE ANY ( '{A, B, C}' ). - If $1 does not contains "O" then $2 is
<= empty string.
But it can't be done. What should I do?