UPDATE
UPDATE bayonoti jadvaldagi mavjud yozuvlarni o'zgartirish uchun ishlatiladi.
SQL UPDATE Bayonoti Nima?
UPDATE bayonoti jadvaldagi mavjud yozuvlarni o'zgartirish uchun ishlatiladi.
UPDATE Sintaksisi
Eslatma: Jadvaldagi yozuvlarni yangilashda ehtiyot bo'ling! UPDATE bayonotidagi WHERE klauzasi qaysi yozuv(lar)ni yangilanishini belgilaydi. Agar WHERE klauzasini e'tiborsiz qoldirsangiz, jadvaldagi barcha yozuvlar yangilanadi!
Demo Ma'lumotlar Bazasi
Quyida misollarda ishlatiladigan Customers jadvalidan tanlov keltirilgan:
CustomerID | CustomerName | ContactName | Address | City | PostalCode | Country |
---|---|---|---|---|---|---|
1 | Alfreds Futterkiste | Maria Anders | Obere Str. 57 | Berlin | 12209 | Germany |
2 | Ana Trujillo Emparedados y helados | Ana Trujillo | Avda. de la Constitución 2222 | México D.F. | 05021 | Mexico |
3 | Antonio Moreno Taquería | Antonio Moreno | Mataderos 2312 | México D.F. | 05023 | Mexico |
4 | Around the Horn | Thomas Hardy | 120 Hanover Sq. | London | WA1 1DP | UK |
5 | Berglunds snabbköp | Christina Berglund | Berguvsvägen 8 | Luleå | S-958 22 | Sweden |
UPDATE Jadvali
Quyidagi SQL bayonoti birinchi mijozni (CustomerID = 1) yangi aloqa shaxsi va yangi shahar bilan yangilaydi:
Misol O'zingizning SQL serveringizni oling
"Customers" jadvalidan olingan tanlov endi quyidagi ko'rinishda bo'ladi:
CustomerID | CustomerName | ContactName | Address | City | PostalCode | Country |
---|---|---|---|---|---|---|
1 | Alfreds Futterkiste | Alfred Schmidt | Obere Str. 57 | Frankfurt | 12209 | Germany |
2 | Ana Trujillo Emparedados y helados | Ana Trujillo | Avda. de la Constitución 2222 | México D.F. | 05021 | Mexico |
3 | Antonio Moreno Taquería | Antonio Moreno | Mataderos 2312 | México D.F. | 05023 | Mexico |
4 | Around the Horn | Thomas Hardy | 120 Hanover Sq. | London | WA1 1DP | UK |
5 | Berglunds snabbköp | Christina Berglund | Berguvsvägen 8 | Luleå | S-958 22 | Sweden |
Bir Nechta Yozuvni Yangilash
WHERE klauzasi qanchalik ko'p yozuv yangilanadiganligini belgilaydi.
Quyidagi SQL bayonoti "Country" qiymati "Mexico" bo'lgan barcha yozuvlarda ContactName ni "Juan" ga yangilaydi:
Misol
"Customers" jadvalidan olingan tanlov endi quyidagi ko'rinishda bo'ladi:
CustomerID | CustomerName | ContactName | Address | City | PostalCode | Country |
---|---|---|---|---|---|---|
1 | Alfreds Futterkiste | Alfred Schmidt | Obere Str. 57 | Frankfurt | 12209 | Germany |
2 | Ana Trujillo Emparedados y helados | Juan | Avda. de la Constitución 2222 | México D.F. | 05021 | Mexico |
3 | Antonio Moreno Taquería | Juan | Mataderos 2312 | México D.F. | 05023 | Mexico |
4 | Around the Horn | Thomas Hardy | 120 Hanover Sq. | London | WA1 1DP | UK |
5 | Berglunds snabbköp | Christina Berglund | Berguvsvägen 8 | Luleå | S-958 22 | Sweden |
Yangilash Ogohlantirishi!
Yozuvlarni yangilashda ehtiyot bo'ling. Agar WHERE klauzasini e'tiborsiz qoldirsangiz, barcha yozuvlar yangilanadi!
Misol
"Customers" jadvalidan olingan tanlov endi quyidagi ko'rinishda bo'ladi:
CustomerID | CustomerName | ContactName | Address | City | PostalCode | Country |
---|---|---|---|---|---|---|
1 | Alfreds Futterkiste | Juan | Obere Str. 57 | Frankfurt | 12209 | Germany |
2 | Ana Trujillo Emparedados y helados | Juan | Avda. de la Constitución 2222 | México D.F. | 05021 | Mexico |
3 | Antonio Moreno Taquería | Juan | Mataderos 2312 | México D.F. | 05023 | Mexico |
4 | Around the Horn | Juan | 120 Hanover Sq. | London | WA1 1DP | UK |
5 | Berglunds snabbköp | Juan | Berguvsvägen 8 | Luleå | S-958 22 | Sweden |