Answer the question
In order to leave comments, you need to log in
Subtracting columns results in a "Numeric value out of range" error, but isn't it that simple?
SELECT (`likes` - `dislikes`) AS `rating` FROM `article`
SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range
Answer the question
In order to leave comments, you need to log in
In short, as I thought :)
www.mysql.ru/docs/man/Column_types.html
Warning: be aware that when performing a subtraction between numeric values, one of which is of type UNSIGNED, the result will be unsigned!
Look at the values in the table for likes, dislikes and their difference. As well as valid values for INT, BIGINT or what type they are assigned there.
https://dev.mysql.com/doc/refman/5.5/en/integer-ty...
Maybe your difference is less than -2147483648 (INT) | -9223372036854775808 (BIGINT)
or greater than 2147483647(INT) | 9223372036854775807(BIGINT)
stackoverflow.com/questions/11698613/bigint-unsign...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question