【SQL语法】系列08:利用Update更新表中数据

语法:

UPDATE 表 SET 列 = 新值 WHERE 列名 = 某值

Person:

LastName

FirstName

Address

City

Gates

Bill

Xuanwumen 10

Beijing

Wilson

 

Champs-Elysees

 

例:更新某一行中的一个列

我们为Lastname 是 "Wilson" 的人添加 firstname:

UPDATE Person SET FirstName = 'Fred' WHERE LastName = 'Wilson'

结果:

LastName

FirstName

Address

City

Gates

Bill

Xuanwumen 10

Beijing

Wilson

Fred

Champs-Elysees

 

例:更新某一行中的若干列

下面我们修改地址(address),并添加城市(city):

UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'

WHERE LastName = 'Wilson'

结果:

LastName

FirstName

Address

City

Gates

Bill

Xuanwumen 10

Beijing

Wilson

Fred

Zhongshan 23

Nanjing

 

你可能感兴趣的:(update)