sql怎么修改表内容


当前第2页 返回上一页

1

2

3

4

5

update test1 set age='23' where id in ('1','2');

update test1 set age='22' where id between '3' and '4';

update test1 set age='23' where id>='5' and id <='6';

update top(2) test1 set age='23' where id>='5';

update test1 set age='23' where test1.id in (select top(2) id from test1 order by id desc);

示例结果:

未标题-2.jpg

未标题-2.jpg

多表关联修改表中数据

语法:update 表1 set 表1.列1=值,表1.列2=值 from 表1 as a,表2 as b where a.列名=b.列名;

示例:

1

update test1 set test1.name='李华',test1.sex='女' from test1 as a,test2 as b where a.classid=b.id;

示例结果:

未标题-2.jpg

未标题-2.jpg

总结:修改数据表数据,灵活组合修改数据列,数据源,查询条件是关键。

以上就是sql怎么修改表内容的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

asp.net下oracle,sql server,access万能数据库通用类

更新基本表中的记录使用的sql命令是什么

浅谈mysql中的group by

sql server 编译与重编译详解

数据库性能优化之sql语句优化

一文带你理解慢sql分析与优化

sql中的cte是什么

oracle数据库中sql语句的优化技巧

sql修改语句怎么写

mysqlsql是什么?mysqlsql之间的区别有哪些

更多相关阅读请进入《sql》频道 >>


数据库系统概念 第6版
书籍

数据库系统概念 第6版

机械工业出版社

本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...