Const// Select course names that are offered in both departments A and B
import { intersect } from 'drizzle-orm/sqlite-core'
await intersect(
db.select({ courseName: depA.courseName }).from(depA),
db.select({ courseName: depB.courseName }).from(depB)
);
// or
await db.select({ courseName: depA.courseName })
.from(depA)
.intersect(
db.select({ courseName: depB.courseName }).from(depB)
);
Adds
intersectset operator to the query.Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.
See docs: https://orm.drizzle.team/docs/set-operations#intersect