เป็นคำสั่งที่ใช้สำหรับแก้ไขข้อมูลในตาราง (Table) โดยสามารถทำการแก้ไขได้หลายฟิวด์และหลาย Record ภายในคำสั่ง 1 คำสั่ง ทั้งนี้ขึ้นอยู่กับ Where ที่ผู้ใช้ได้เขียนขึ้น
Database : MySQL,Microsoft Access,SQL Server,Oracle
Syntax
UPDATE [Table-Name] SET Column1='Value1',Column2='Value2',... WHERE clause
Table : country
CountryCode 
 | 
CountryName 
 | 
|---|---|
TH 
 | Thailand | 
EN 
 | English | 
US 
 | United states | 
CH 
 | Chaina | 
Sample1 การแก้ไขข้อมูลลงใน Table
UPDATE country SET CountryCode = 'JP',CountryName='Japan' WHERE CountryCode = 'CH'
Output
CountryCode 
 | 
CountryName 
 | 
|---|---|
TH 
 | Thailand | 
EN 
 | English | 
US 
 | United states | 
JP 
 | Japan | 
ที่มา : http://www.thaicreate.com/tutorial/sql-update.html
ไม่มีความคิดเห็น:
แสดงความคิดเห็น