如何更新特定 ID 的列

问题描述 投票:0回答:2

更新批量 ID 集的特定列。 例如:

+-------+---------------------------+----------------------------------+
| id    | name                      | companyname                      |
+-------+---------------------------+----------------------------------+
| 1     |   BABAK TAVAKOLI          | FIRE PROTECTION                  |
| 2     |   BRIAN CHRISTOPHER RISI  | CORPORATION SYSTEMS              |
| 3     |   CHRISTIAN DOMINIK NAVAR | BUILD INC                        |
| 4     |   CHRISTIAN DOMINIK NAVAR | UNITED INC                       |
| 5     |   GABRIEL ALVAREZ         | G A BUILD                        |
+-------+---------------------------+----------------------------------+

这个表总共1000条记录,我想特别更新1-250列

UPDATE productsale SET companyname = '****' WHERE id = 1 to 250;
updates mysql-python
2个回答
0
投票

更新产品销售集公司名称 = '****' 其中 id >= 1 且 id < 250


0
投票

您必须使用关键字

BETWEEN
而不是
TO
,格式如下:
UPDATE productsale SET companyname = '****' WHERE id BETWEEN 1 AND 250

© www.soinside.com 2019 - 2024. All rights reserved.