Const// Select all unique names from customers and users tables
import { union } from 'drizzle-orm/sqlite-core'
await union(
db.select({ name: users.name }).from(users),
db.select({ name: customers.name }).from(customers)
);
// or
await db.select({ name: users.name })
.from(users)
.union(
db.select({ name: customers.name }).from(customers)
);
Adds
unionset operator to the query.Calling this method will combine the result sets of the
selectstatements and remove any duplicate rows that appear across them.See docs: https://orm.drizzle.team/docs/set-operations#union