Question

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
Était-ce utile?

La solution

You can try this one:

SELECT CAST(UnitsInStock AS SIGNED) - CAST(UnitsOnOrder AS SIGNED) as 'Difference' FROM products
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top