سؤال

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