萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> SQL UPDATE 語句,語法及用法

SQL UPDATE 語句,語法及用法


Update 語句用於修改表中的數據。

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




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


copyright © 萬盛學電腦網 all rights reserved