© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
1 reply
xeon06

Select fields with the same name in two different tables in a join

Is it possible to select two fields of the same name, but from a different table, as part of a join? e.g.

    db
    .select({
      inboxCurrencyCode: inboxes.currencyCode,
      cardCurrencyCode: cards.currencyCode,
    })
    .from(transactions)
    .leftJoin(inboxes, eq(transactions.inboxId, inboxes.id))
    .leftJoin(cards, eq(transactions.cardId, cards.id))
    db
    .select({
      inboxCurrencyCode: inboxes.currencyCode,
      cardCurrencyCode: cards.currencyCode,
    })
    .from(transactions)
    .leftJoin(inboxes, eq(transactions.inboxId, inboxes.id))
    .leftJoin(cards, eq(transactions.cardId, cards.id))


As-is, it only ever gives me one of two
currencyCode
currencyCode
fields, even if they are technically renamed by the partial
select
select
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

Postgres tables with same name but different schema
Drizzle TeamDTDrizzle Team / help
16mo ago
Cannot join tables where the columns name are the same.
Drizzle TeamDTDrizzle Team / help
3y ago
How to join tables from different dbs in same db cluster?
Drizzle TeamDTDrizzle Team / help
3y ago
[BUG] Multi schema tables with same name
Drizzle TeamDTDrizzle Team / help
3y ago