-
Notifications
You must be signed in to change notification settings - Fork 0
Nested Queries
Christoph Herrmann edited this page Sep 6, 2019
·
2 revisions
Nested Queries are supported by using SQL Tag queries as variables of other SQL Tag queries.
const state = 'active'
const email = 'email'
const name = 'name'
const result = await sql.query(sql`
SELECT * FROM users WHERE
state = ${state}
AND
id = (${sql`SELECT id FROM users WHERE email = ${email} AND name = ${name}`})
`)
// text: SELECT * FROM users WHERE
// state = $1
// AND
// id = (SELECT id FROM users WHERE email = $2 AND name = $3)
// parameters: ['active', 'email', 'name']
Found a bug or missing a feature? -> Create a new Issue
Found a security issue? -> Look at the Security Policy
Having questions, want to give feedback or talk to me? -> E-Mail me [email protected]