c语言sscanf函数的用法是什么
256
2022-09-01
sql 练习系列:数据的更新操作
还是接着上一篇博文,我们继续。。。
本文主要练习更新操作,在mysql中实现。
内容相对上一篇博文较少,这是那三张表:
修改“计算机学院”的“李勇”同学的名字为“李咏”
如果仅有一个sno主键那么:
update s set sname='李咏' where sno='20130101' and sdept ='computer';
--必须写成-->
alter table s drop primary key;alter table s add primary key(sname);update s set sname='李咏' where sname='李勇' and sdept ='computer';
这样的话,后期诸多的更新操作会很麻烦,所以干脆把所有涉及到更新的字段统统设置成primary key的属性
alter table s drop primary key;alter table s add primary key(sname,sno,sid,sdept,sage);
将选修了 10001 课程的学生的分数设置为 60 分
update sc set grade=60 where cno='1001';
将选修了“大学英语”课程的学生的分数增加
5 分
update sc set grade=grade+5 where sc.cno=(select cno from c where c.cname='大学英语');
将“计算机学院”的学生的“高等数学”课程的成绩设置为
NULL
Update sc set grade=null where cno=(select cno from c where cname='高数') and sno in (select sno from s where sdept='computer');/* cno和sno必有一个是=,不能同时是in */
删除计算机学院年龄大于 25 岁的男生
Delete from s where sdept='computer' and sage>25 and ssex='男';
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~