MYSQL查询减去运算符不工作

时间:2014-01-17 22:53:12

标签: mysql sql unsigned bigint outofrangeexception

在MYSQL中查找有关使用减号运算符的错误的所有问题,但无法找到解决方案。 所有给定的解决方案无效。 我试图区分库存单位和订单单位 我的查询是这样的:

$sql = "SELECT   UnitsInStock - UnitsOnOrder as 'Difference'
        FROM products ";

为什么我收到此错误?

 Warning: mysqli_query(): (22003/1690): BIGINT UNSIGNED value is out of range

1 个答案:

答案 0 :(得分:2)

你可以尝试这个:

SELECT CAST(UnitsInStock AS SIGNED) - CAST(UnitsOnOrder AS SIGNED) as 'Difference' FROM products