删除某个学校某个年级的学生信息

insert into "B_Student_del"
select s.* from "B_Student" s 
join "B_Class" cla on cla."ClassID"=s."ClassID" 
join "B_Grade" gra on gra."GradeID"=cla."GradeID" and gra."StudyYearID"=2019 
join "B_School" sch on sch."SchoolID"=gra."SchoolID" and sch."SchoolID"=35;

DELETE from "B_Student" where "StudentID" in (select s."StudentID" from "B_Student" s 
join "B_Class" cla on cla."ClassID"=s."ClassID" 
join "B_Grade" gra on gra."GradeID"=cla."GradeID" and gra."StudyYearID"=2019 
join "B_School" sch on sch."SchoolID"=gra."SchoolID" and sch."SchoolID"=35) RETURNING *

 

上一篇:robot framework——链接和断开mysql数据库


下一篇:mysql查询班级以及相关的上课教师(列合并)