What syntax does PG want me to use?

Posted on

Question :

I have:

SELECT * FROM table WHERE textcol NOT IN $1;

I get:

ERROR:  syntax error at or near "$1"

$1 is sent as an array of strings from the application. Parameterized query. pglib. PHP.

Answer :

Not sure how your PHP lib handles arrays, but the correct Pg syntax for IN certainly requires parentheses.

You probably want the query to look more like:

SELECT * FROM table WHERE textcol NOT IN ($1);

Leave a Reply

Your email address will not be published. Required fields are marked *