I'm fetching comments and sorting them by their score (
upvotes-downvotes). However if a comment has not been voted on at all, then it has NULL upvotes & downvotes, and so ones that are negative will be displayed first.
cv_type = 1, downvotes are
cv_type = 0.
(select sum(IF( cv.cv_type= '1', 1 , 0 )) from comment_votes cv where cv_commentid=comments.c_id ) as upvotes,
(select sum(IF( cv.cv_type= '0', 1 , 0 )) from comment_votes cv where cv_commentid=comments.c_id ) as downvotes
INNER JOIN users
ON u_id = c_userid
WHERE c_postid = ? AND c_parentid = 0
ORDER BY upvotes-downvotes
DESC LIMIT 100
Any way to make sure ones without votes are above ones that are negative?