我正在尝试删除学生表中加入学生班级的第一行,方法是在学生表中使用学生的第一,中间和姓氏以及出生日期,该表引用Student_Class表中的CLASS。我尝试过使用以下语句,但似乎没有用。
delete from student where student.stu_id = (select student_class.stu_id from
student_class left outer join student on student.stu_id =
student_class.stu_id where student.first_name = 'Junior' AND
student.middle_name = 'Mills' AND student.last_name = 'Prince' AND
student.dob = '2015-10-02' AND student.sch_id = '2' AND student_class.class
= 'J.H.S. 1');
还有:
delete student.* from student inner join student_class on
student_class.stu_id = student.stu_id where student.stu_id = (select
student_class.stu_id from student_class left outer join student on
student.stu_id = student_class.stu_id where student.first_name = 'Junior'
AND student.middle_name = 'Mills' AND student.last_name = 'Prince' AND
student.dob = '2015-10-02' AND student.sch_id = '2' AND student_class.class
= 'J.H.S. 1');
答案 0 :(得分:0)
您还没有为删除做过简单的连接: -
DELETE a
FROM student a
INNER JOIN student_class b
ON a.stu_id = b.stu_id
WHERE a.first_name = 'Junior'
AND a.middle_name = 'Mills'
AND a.last_name = 'Prince'
AND a.dob = '2015-10-02'
AND a.sch_id = '2'
AND b.class = 'J.H.S. 1'
但您似乎想要从 student 表(而不是 student_class 表)中删除记录,并且几乎指定了来自的所有标识字段>学生表。无论如何。