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
I need to do a SELECT IN query - to select multiple rows, but can't seem to do it. I tried many ways -
const ids = ['aaa', 'bbb', 'ccc']; const {rows} = sql`select * from my_table where id in (${ids})`;
I also tried concatenating the ids on my own, but it also doesn't seem to work.
How would I execute a query like this ?
The text was updated successfully, but these errors were encountered:
Right now, you'll have to fall back to creating the query and calling sql.query yourself -- SQL templating is very limited:
sql.query
const query = 'SELECT * FROM users WHERE id IN ($1, $2, $3)' const params = [1234, 2345, 3456] await sql.query(query, params)
However, when/if #504 merges, something like this will be possible:
await sql`SELECT * FROM users WHERE id IN (${LIST(params)})`
So hopefully you don't have to manually build more-complex queries for too long!
Sorry, something went wrong.
That TQL syntax looks great, would happy to see it merged. For now, thanks a lot for the response, I appreciate it :)
No branches or pull requests
I need to do a SELECT IN query - to select multiple rows, but can't seem to do it. I tried many ways -
I also tried concatenating the ids on my own, but it also doesn't seem to work.
How would I execute a query like this ?
The text was updated successfully, but these errors were encountered: