Вопрос

Looked up of all questions about error with minus operator in MYSQL and can't find solution. all given solutions not working. i`m trying to get difference between Units In Stock and Units On Order and my query like this:

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

why i got this error?

 Warning: mysqli_query(): (22003/1690): BIGINT UNSIGNED value is out of range
Это было полезно?

Решение

You can try this one:

SELECT CAST(UnitsInStock AS SIGNED) - CAST(UnitsOnOrder AS SIGNED) as 'Difference' FROM products
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top