我在MySql字段中的项目格式为:FK1
FK2
FK3
,最多为FK1000
。发生的事情是当我运行UPDATE
查询时,如下所示,它会更新FK10
和FK100
等项目。我试图使用between语句将项目从FK1
更新为FK20
。为什么还要更新项FK101
,FK102
等
UPDATE `boxes`
SET intake_date = '2015-12-17 10:09:11'
WHERE customer = 'demo'
AND custref BETWEEN 'fk1' AND 'fk20';
非常感谢
答案 0 :(得分:1)
试试这个:
UPDATE `boxes` SET intake_date = '2015-12-17 10:09:11' WHERE customer = 'demo' AND cast(substring(custref, 3) AS SIGNED) BETWEEN 1 AND 20
它剥离了前导FK,并转换为整数,因此顺序正确。