sql update

6 Sep 2015

Share to:

sql update เป็นคําสั่งที่ใช้สําหรับแก้ไขข้อมูลในตาราง สามารถแก้ไขข้อมูลได้หลาย Field และหลาย Record โดยจะขึ้นอยู่กับ Where ที่ผู้ใช้กําหนด

Database support

MySQL,Microsoft Access,SQL Server,Oracle

รูปแบบการใช้

UPDATE [Table-Name] SET Column1='Value1',Column2='Value2',... WHERE clause

parameter

  • [Table-Name] คือ ชื่อของตารางที่ต้องการ
  • clause คือ เงื่อนไขที่ต้องการ
  • Column1=‘Value1’,Column2=‘Value2’,… คือ Column ที่ต้องการแก้ไข

Example

Table : country

CountryCode

CountryName

TH

Thailand

EN

English

US

United states

CH

Chaina

เมื่อต้องการแก้ไขข้อมูล CountryCode = ‘JP’,CountryName=‘Japan’ ใน Record CountryCode=‘CH’

UPDATE country SET CountryCode = 'JP',CountryName='Japan' WHERE CountryCode = 'CH'

Output:

CountryCode

CountryName

TH

Thailand

EN

English

US

United states

JP

Japan

ข้อมูลจาก thaicreate


Copyright © 2019 - 2024 thiti.dev |  v1.19.0 |  Privacy policy |  status | 

            วงแหวนเว็บ