当前位置:网站首页>MySQL - 更新表中的数据记录
MySQL - 更新表中的数据记录
2022-07-24 10:25:00 【骆驼胡杨】
更新表中的数据记录
- 更新数据记录是数据操作中常见的操作,可以更新表中已经存在数据记录中的值。在MySQL中可以通过UPDATE语句来实现更新数据记录,该SQL语句可以通过如下几种方式使用:更新特定数据记录、更新所有数据记录、更新JSON结构的数据记录。
1. 更新特定数据记录
在MySQL中更新特定数据记录可通过SQL语句UPDATE来实现,其语法形式如下:
UPDATE tablename SET field1 = value1, field2 = value2, field3 = value3, ..., fieldn = valuen) WHERE CONDITION;上述语句中,参数tablename表示所要更新数据记录的表名,参数field表示表中所要更新数值的字段名字,参数valuen表示更新后的数值,参数CONDITION指定更新满足条件的特定数据记录。
mysql> create table class(id int, name varchar(64), addr varchar(64)); mysql> insert into class values(1, '张三', '俄罗斯'); mysql> insert into class values(2, '李四', '美国'); mysql> UPDATE class SET addr='韩国' WHERE addr='俄罗斯'; //将地址为俄罗斯更新为韩国 mysql> select * from class;
2 .更新所有数据记录
在MySQL中更新特定数据记录可通过SQL语句UPDATE来实现,其语法形式如下:
UPDATE tablename SET field1 = value1, field2 = value2, field3 = value3, ..., fieldn = valuen) WHERE CONDITION; 或 UPDATE tablename SET field1 = value1, field2 = value2, field3 = value3, ..., fieldn = valuen) ;在上述语句中,参数tablename表示所要更新数据记录的表名,参数field表示表中所要更新数值的字段名字,参数valuen表示更新后的数值,参数CONDITION表示满足表tablename中的所有数据记录,或不使用关键字WHERE语句。
mysql> create table class(id int, name varchar(64), addr varchar(64)); mysql> insert into class values(1, '张三', '俄罗斯'); mysql> insert into class values(2, '李四', '美国'); mysql> UPDATE class SET addr='中国'; //将所有数据的地址都更新为中国 mysql> select * from class;
边栏推荐
- TypeError: Object of type ‘int32‘ is not JSON serializable
- Knapsack problem of dynamic programming -- three lectures on knapsack (01 knapsack, complete knapsack, multiple knapsack)
- 图像处理:RGB565转RGB888
- 2022, enterprise informatization construction based on Unified Process Platform refers to thubierv0.1
- Create a vertical seekbar from scratch
- Curse of knowledge
- Websocket 协议解读-RFC6455
- [STM32 learning] (7) use of serial port 2 (usart2)
- [sword finger offer II 115. reconstruction sequence]
- Query about operating system security patch information
猜你喜欢

Will not be rejected! Learn the distributed architecture notes sorted out by Alibaba Daniel in 35 days, with a salary increase of 20K

CMS vulnerability recurrence - foreground arbitrary user password modification vulnerability

ffmpeg花屏解决(修改源码,丢弃不完整帧)

Dynamic programming -- a collection of stock problems
![[STM32 learning] (12) STM32 realizes LCD1602 simple static reality](/img/78/954ebaae0cce5d9387e7032fa85e60.png)
[STM32 learning] (12) STM32 realizes LCD1602 simple static reality

New:Bryntum Grid 5.1.0 Crack

Ribbon's loadbalancerclient, zoneawareloadbalancer and zoneavoidancerule are three musketeers by default

Differential restraint system -- 1 and 2 -- May 27, 2022

The paper of gaojingjian center was selected into the ACL 2022 of the international summit to further expand the privacy computing capacity of Chang'an chain

When the hot tea is out of stock, what does the new tea drink rely on to continue its life?
随机推荐
[STM32 learning] (8) stm32f1 general timer configuration
Set scrolling for the box
Notes on using setupproxy
String__
Segment tree--
Kotlin Advanced Grammar
[STM32 learning] (14) two 74HC595 controls four nixie tube displays
[STM32 learning] (16) STM32 realizes LCD1602 display (74HC595 drive) - 4-bit bus
Will not be rejected! Learn the distributed architecture notes sorted out by Alibaba Daniel in 35 days, with a salary increase of 20K
Selnium checks three conditions when it cannot locate an element
System a uses window.open to call system B, and system B carries data back to system a after processing the business
JSON tutorial [easy to understand]
Create a vertical seekbar from scratch
Interpretation of websocket protocol -rfc6455
Basic SQL operations
常量指针、指针常量
Is CITIC Securities a safe and reliable securities firm? How to open an account?
图像处理:浮点数转定点数
zoj 2770 差分约束系统---2--2022年5月20日
Chapter V Modification implementation (impl) class