[英]Why do I get a syntax error when using CAST in MySQL?
I am using MySQL workbench v5.2.44 CE. 我正在使用MySQL workbench v5.2.44 CE。 I am running it against a local MySQL 5.5 install.
我正在针对本地MySQL 5.5安装运行它。
I am trying to use the CAST
function, but keep getting the following error: 我正在尝试使用
CAST
函数,但不断收到以下错误:
syntax error, unexpected INT_SYM
语法错误,意外的INT_SYM
It doesn't matter what the source and target date types are. 源和目标日期类型无关紧要。 The only time it doesn't give me an error is when the target datatype is
DECIMAL
. 当目标数据类型为
DECIMAL
时,它唯一没有给出错误的时间。 Here is an example: 这是一个例子:
SELECT CAST(IFNULL(comboCount, 1) * COUNT(partID) AS INT) INTO comboCount
FROM productOption
I have tried everything, but nothing seems to work. 我已经尝试了一切,但似乎没有任何效果。
Try to do the math outside: 尝试在外面做数学:
SELECT CAST(IFNULL(comboCount, 1) AS INT) * COUNT(partID) INTO comboCount
FROM productOption
If that doesn't work, try to CAST
as UNSIGNED
; 如果这不起作用,请尝试
CAST
为UNSIGNED
; not INT
. 不是
INT
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.