其他分享
首页 > 其他分享> > 删除某个学校某个年级的学生信息

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

作者:互联网

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 *

 

标签:ClassID,SchoolID,join,sch,删除,cla,gra,某个,年级
来源: https://www.cnblogs.com/pengyong1211/p/11647849.html