I have a blog. I wrote simple voting system. I might be wrong about the idea. i have a table like this
id title article TotalVotes VoteSum
when someone upvote article TotelVotes gets one point if someone downvote the article the VoteSum cloumn gets 1 point
when I display the article’s vote i do this
<?php
$Vote = $ROW['TotelVotes']-$ROW['VoteSum'];
?>
it works just fine but on my front page I want to show top articles so I made this mysql query
SELECT TotalVotes-VoteSum AS diff FROM `articles` ORDER BY `diff` DESC
when i do this I recieve numbers like this 18446744073709551615 this happens for example when TotalVotes less than VoteSum
DATA TYPE IS INT UNSIGNED
what do I do wrong? Could you please help me? thanks.
you can use
IFUPDATE
if you want to get negative values, make those columns as
INT SIGNEDso you can get negatives. And directly run your own query,