我想做的事情如下:
DELETE FROM student WHERE student.course, student.major IN (SELECT schedule.course, schedule.major FROM schedule)
但是,您似乎只能在IN运算符中使用一列.真的吗?看起来像这样的查询应该是可能的.
不,你只需要括号:
DELETE FROM student WHERE (student.course, student.major) IN (SELECT schedule.course, schedule.major FROM schedule)
您还可以使用EXISTS子句:
DELETE FROM student WHERE EXISTS ( SELECT 1 FROM schedule WHERE schedule.course=student.course AND schedule.major=student.major )
DELETE FROM student WHERE (student.course, student.major) IN (SELECT schedule.course, schedule.major FROM schedule)
在where子句中围绕您的条款添加parens.干杯!