博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql 中使用 update 同时更新多个字段
阅读量:4229 次
发布时间:2019-05-26

本文共 1619 字,大约阅读时间需要 5 分钟。

update 表名 set 字段1=新值1, 字段2=新值2, 字段3=新值3, ... where 条件
mysql> select * from tb_person;+----+----------+-------------+------+------+-------------+---------------------+| id | name     | phone       | age  | sex  | description | create_time         |+----+----------+-------------+------+------+-------------+---------------------+|  1 | zhangsan | 132****2889 |   25 | M    | NoDesc      | 2020-11-30 20:03:07 ||  3 | lisi     | 152****7873 |   18 | F    | None        | 2020-11-30 20:08:33 ||  5 | wangwu   | 136****2908 |   25 | M    | Nothing     | 2020-11-30 20:10:11 || 10 | zhaoliu  | 138****5322 |   15 | M    | Nothing     | 2020-11-30 20:12:11 |+----+----------+-------------+------+------+-------------+---------------------+4 rows in set (0.00 sec)mysql> update tb_person set name='looking', age=26, phone='152****9066' where id=10;Query OK, 1 row affected (0.00 sec)Rows matched: 1  Changed: 1  Warnings: 0mysql> select * from tb_person;+----+----------+-------------+------+------+-------------+---------------------+| id | name     | phone       | age  | sex  | description | create_time         |+----+----------+-------------+------+------+-------------+---------------------+|  1 | zhangsan | 132****2889 |   25 | M    | NoDesc      | 2020-11-30 20:03:07 ||  3 | lisi     | 152****7873 |   18 | F    | None        | 2020-11-30 20:08:33 ||  5 | wangwu   | 136****2908 |   25 | M    | Nothing     | 2020-11-30 20:10:11 || 10 | looking  | 152****9066 |   26 | M    | Nothing     | 2020-11-30 20:12:48 |+----+----------+-------------+------+------+-------------+---------------------+4 rows in set (0.01 sec)

 

转载地址:http://bnjqi.baihongyu.com/

你可能感兴趣的文章
Computer Security Basics
查看>>
Sams Teach Yourself MySQL in 10 Minutes
查看>>
Information Systems : The State of the Field
查看>>
IPv6 Essentials
查看>>
Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner
查看>>
Microsoft Visual Basic 2005 Express Edition Programming for the Absolute Beginner
查看>>
Pro .NET 2.0 Windows Forms and Custom Controls in C#
查看>>
Beginning Regular Expressions
查看>>
Beginning Visual Web Developer 2005 Express: From Novice to Professional
查看>>
Beginning Programming
查看>>
Windows .NET Server 2003 Domains & Active Directory
查看>>
Information Systems : Achieving Success by Avoiding Failure
查看>>
Web Systems Design and Online Consumer Behavior
查看>>
VoIP For Dummies
查看>>
Administrator's Guide to SQL Server 2005
查看>>
Ajax Design Patterns
查看>>
DNS and BIND (5th Edition)
查看>>
Firewall Fundamentals
查看>>
Learning PHP and MySQL
查看>>
Agile Software Construction
查看>>