© 2026 Hedgehog Software, LLC

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

one to many query

In Drizzle you can make a one to many query like this:
const result = await db.query.users.findMany({
    with: {
        posts: true            
    },
});
const result = await db.query.users.findMany({
    with: {
        posts: true            
    },
});

with that query I get the user and its posts

there are some questions that I have

1. Can I use pure SQL in that query that uses the ORM-like syntax?
2. how can I write a query with the SQL-like syntax that allows me to select for each table separate fields
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

Query only one item from Many-To-Many
Drizzle TeamDTDrizzle Team / help
3y ago
one-to-many
Drizzle TeamDTDrizzle Team / help
3y ago
Many to Many Query With
Drizzle TeamDTDrizzle Team / help
17mo ago
query with one to many (postgres + foreign keys)
Drizzle TeamDTDrizzle Team / help
2y ago