错误代码:1292 - 截断不正确的 DOUBLE 值:'-' [英] Error Code: 1292 - Truncated Incorrect DOUBLE value: '-'

查看:91
本文介绍了错误代码:1292 - 截断不正确的 DOUBLE 值:'-'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SET @newNum = IF(
    RIGHT("-600.00",1) REGEXP '^[-]' = '-',
    REPLACE("-600.00",",",""),
    -1*REPLACE(REPLACE("-600.00",",",""),"-","")
);

我不断收到一个被截断的不正确的 DOUBLE 值:'-' 执行此行时,有人知道是什么原因造成的吗?

I keep getting a truncated incorrect DOUBLE value: '-' when executing this line, anyone know what is causing this ?

推荐答案

REGEXP 返回 1 或 0,具体取决于是否匹配.将结果与 - 进行比较是不正确的,您可以这样做:

REGEXP returns 1 or 0 depending on whether there is a match or not. Comparing the result with - is incorrect, you can do this instead:

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

这篇关于错误代码:1292 - 截断不正确的 DOUBLE 值:'-'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆