Const// Select all transaction ids from both online and in-store sales
import { unionAll } from 'drizzle-orm/sqlite-core'
await unionAll(
db.select({ transaction: onlineSales.transactionId }).from(onlineSales),
db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
);
// or
await db.select({ transaction: onlineSales.transactionId })
.from(onlineSales)
.unionAll(
db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
);
Adds
union allset operator to the query.Calling this method will combine the result-set of the
selectstatements and keep all duplicate rows that appear across them.See docs: https://orm.drizzle.team/docs/set-operations#union-all