当前位置: 首页 > 网络学院 > 服务端脚本教程 > SQL > SQL Update

SQL
SQL Create View
SQL Server
SQL 速查
SQL 摘要
MYSQL 列类型存储需求

SQL Update


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1010 ::
收藏到网摘: n/a

The Update Statement
Update 声明

The UPDATE statement is used to modify the data in a table.
UPDATE 声明可用来更新数据表中的数据

语法

UPDATE table_name
SET column_name = new_value WHERE column_name = some_value


Person:

LastName FirstName Address City
Nilsen Fred Kirkegt 56 Stavanger
Rasmussen   Storgt 67  


Update one Column in a Row
更新记录行中的一个栏目

We want to add a first name to the person with a last name of "Rasmussen":
我们将给person表中LastName为"Rasmussen"的数据添加一个first name值

UPDATE Person SET FirstName = 'Nina'
WHERE LastName = 'Rasmussen'

结果:

LastName FirstName Address City
Nilsen Fred Kirkegt 56 Stavanger
Rasmussen Nina Storgt 67  


Update several Columns in a Row
给一记录行更新多个栏目

We want to change the address and add the name of the city:
我们将个人信息中Lastname为"Rasmussen"的所在城市名和地址做一次改变:

UPDATE Person
SET Address = 'Stien 12', City = 'Stavanger'
WHERE LastName = 'Rasmussen'

结果:

LastName FirstName Address City
Nilsen Fred Kirkegt 56 Stavanger
Rasmussen Nina Stien 12 Stavanger

评论 (0) All

登陆 | 还没注册?