update multi rows using only one sql; 一句 sql update 多行数据

Posted 厚积_薄发

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了update multi rows using only one sql; 一句 sql update 多行数据相关的知识,希望对你有一定的参考价值。

mysql> select * from states;
+----+---------+------------+
| id | state   | population |
+----+---------+------------+
|  1 | Alabama |    4822026 |
|  2 | bbb     |      33444 |
|  3 | Alabama |    4822024 |
|  4 | ccc     |         44 |
|  5 | ddd     |          5 |
+----+---------+------------+
5 rows in set (0.00 sec)


mysql> INSERT INTO states (id, population) VALUES (4, 444), (5, 555) ON DUPLICATE KEY UPDATE id=values(id), population=values(population);
Query OK, 4 rows affected (0.00 sec)
Records: 2  Duplicates: 2  Warnings: 0


mysql> select * from states;                                                                                                      +----+---------+------------+
| id | state   | population |
+----+---------+------------+
|  1 | Alabama |    4822026 |
|  2 | bbb     |      33444 |
|  3 | Alabama |    4822024 |
|  4 | ccc     |        444 |
|  5 | ddd     |        555 |
+----+---------+------------+

以上是关于update multi rows using only one sql; 一句 sql update 多行数据的主要内容,如果未能解决你的问题,请参考以下文章

异常:Batch update returned unexpected row count from update [0]; actual row count: 0;

关于Error during managed flush [Batch update returned unexpected row count from update [0]; actual row

IllegalArgumentException:@Body parameters cannot be used with form or multi-part encoding

Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields(翻译)

图神经网络多模态检索Multi-Modal Retrieval using Graph Neural Networks

多任务学习Multi-Task Learning Using Uncertainty to Weigh Losses for Scene Geometry and Semantics