学生表、课程表,学生课程关系表中怎么修改学生id信息
来源:百度知道 编辑:UC知道 时间:2024/06/23 08:27:45
问题1:原学生表中没有学号是1的??,如果没有可以改
update student set Stuid=1 where Stuid=(select stuid from card where score=100 and cid=(select cid from course where cmane='物理')) and sname='张三'
这个表改后card 表里相应的张三的数据就与student表里不相符了.
delete from student where Stuid in (select stuid from card where score<60 and cid=(select cid from course where cname='英语'))
同样的删除数据后,找不到对应的student表里的
这种结构的表之间应该还有外键关联
像你这么改要乱套的
1、
update a set a.StuId='1' from student a inner join card b on a.StuId=b.stuId inner join course c on b.cid=c.cid where c.cname='物理' and b.score=100 and a.sname='张三’
2、
delete from student a inner join card b on a.StuId=b.stuId inner join course c on b.cid=c.cid where c.cname='英语' and b.score<60
以上,希望对你有所帮助
1
update student set s.StuId='1' from student s inner join course co on s.StuId=co.stuid inner join card ca on co.cid=ca.cid where