错误代码:1292 - 截断不正确的 DOUBLE 值:'-'
Error Code: 1292 - Truncated Incorrect DOUBLE value: '-'
SET @newNum = IF(
RIGHT("-600.00",1) REGEXP '^[-]' = '-',
REPLACE("-600.00",",",""),
-1*REPLACE(REPLACE("-600.00",",",""),"-","")
);
执行此行时,我不断收到截断的不正确 DOUBLE 值:'-',有人知道是什么原因造成的吗?
REGEXP
returns 1 或 0 取决于是否匹配。将结果与 -
进行比较是不正确的,您可以这样做:
DECLARE @oldNum VARCHAR(10);
DECLARE @newNum VARCHAR(10);
SET @oldNum = '600.00-';
SET @newNum = IF(
RIGHT(@oldNum, 1) = '-',
CONCAT('-', REPLACE(REPLACE(@oldNum, ',', ''), '-', '')),
REPLACE(@oldNum, ',', '')
);
SELECT @oldNum, @newNum
SET @newNum = IF(
RIGHT("-600.00",1) REGEXP '^[-]' = '-',
REPLACE("-600.00",",",""),
-1*REPLACE(REPLACE("-600.00",",",""),"-","")
);
执行此行时,我不断收到截断的不正确 DOUBLE 值:'-',有人知道是什么原因造成的吗?
REGEXP
returns 1 或 0 取决于是否匹配。将结果与 -
进行比较是不正确的,您可以这样做:
DECLARE @oldNum VARCHAR(10);
DECLARE @newNum VARCHAR(10);
SET @oldNum = '600.00-';
SET @newNum = IF(
RIGHT(@oldNum, 1) = '-',
CONCAT('-', REPLACE(REPLACE(@oldNum, ',', ''), '-', '')),
REPLACE(@oldNum, ',', '')
);
SELECT @oldNum, @newNum