Oracle Delete Rows Matching On Multiple Values

前端 未结 6 1125
暖寄归人
暖寄归人 2020-12-24 01:58

I want to do something like:

DELETE FROM student WHERE
student.course, student.major IN
(SELECT schedule.course, schedule.major FROM schedule)
6条回答
  •  长情又很酷
    2020-12-24 02:37

    Note that if any attributes are null, the row's considered not IN. That is, if courses are equal and both student and schedule major are null, row will not be deleted.

    If an attribute, such as major, may be null, and you want null = null to be true, try:

    DELETE
    FROM student
    WHERE (student.course, NVL(student.major,'sOmeStRinG') )
    IN (SELECT schedule.course, NVL(schedule.major,'sOmeStRinG') FROM schedule)
    

提交回复
热议问题