Subquery in Delete

what is the correct way to write a delete statement with a subquery? example not working:
const department = db
.select()
.from(baseDepartment)
.where(eq(baseDepartment.id, 21))
.as("sq");

const a = await db
.with(department)
.delete(baseDepartment)
.where(eq(baseDepartment.id, department.id));
const department = db
.select()
.from(baseDepartment)
.where(eq(baseDepartment.id, 21))
.as("sq");

const a = await db
.with(department)
.delete(baseDepartment)
.where(eq(baseDepartment.id, department.id));
error I am getting is: Missing from cause value for "sq"
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server