更新批量 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;
更新产品销售集公司名称 = '****' 其中 id >= 1 且 id < 250
您必须使用关键字
BETWEEN
而不是 TO
,格式如下:UPDATE productsale SET companyname = '****' WHERE id BETWEEN 1 AND 250