© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
10 replies
francis

How do you create a scalar subquery in drizzle?

I want to create the drizzle analog of
select * from table_a where id = (select a_id from table_b where id = <....>)
select * from table_a where id = (select a_id from table_b where id = <....>)


This works in raw SQL, but I'm not sure how to construct the subquery to get only the
a_id
a_id
field to supply in the where condition.

drizzle.select().from(tableA).where(eq(tableA.id, drizzle.select(<WHAT GOES HERE>).from(tableB).where(eq(tableB.id, userInputBId))))
drizzle.select().from(tableA).where(eq(tableA.id, drizzle.select(<WHAT GOES HERE>).from(tableB).where(eq(tableB.id, userInputBId))))
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Drizzle join in a subquery results in ambiguous columns
Drizzle TeamDTDrizzle Team / help
3y ago
Struggling with simple subquery statement in Drizzle
Drizzle TeamDTDrizzle Team / help
16mo ago
[pg] How do I make subquery in select()?
Drizzle TeamDTDrizzle Team / help
3y ago
How do I write a subquery inside select?
Drizzle TeamDTDrizzle Team / help
2y ago