We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IN
Heya, how would one go about passing parameters to a query with IN?
For example:
SELECT * FROM people WHERE name in ($1)
I've tried to use:
pg.query(query, [['drake', 'zoey']], cb)
But I don't get results back when both drake and zoey are in the table.
drake
zoey
However the following does seem to work:
pg.query(query.replace(/\$1/, ['drake', 'zoey'].map(v => `'${v}'`).join(','), cb)
The text was updated successfully, but these errors were encountered:
You can use = ANY instead:
= ANY
SELECT * FROM people WHERE name = ANY ($1)
Sorry, something went wrong.
Duplicate of #1452
However the following does seem to work: pg.query(query.replace(/\$1/, ['drake', 'zoey'].map(v => `'${v}'`).join(','), cb)
(and, to be clear, definitely do not do this. It’s an SQL injection vulnerability.)
<3 thank you
No branches or pull requests
Heya, how would one go about passing parameters to a query with
IN
?For example:
I've tried to use:
But I don't get results back when both
drake
andzoey
are in the table.However the following does seem to work:
The text was updated successfully, but these errors were encountered: