You can do stupid tricks with SUM:
SELECT commentid, SUM(positive) upvotes, SUM(NOT positive) downvotes FROM commentvotes;
MySQL booleans are actually just integers, 0 or 1. Adding them effectively counts how many times the condition is true. Therefore, if you have:
commentid | positive
----------|---------
1 | true
1 | true
1 | false
1 | true
1 | false
SUM(positive) 1+1+0+1+0= 3. SUM(NOT positive) is 0+0+1+0+1= 2. , .
: MySQL , positive TINYINT(1) , , SUM(positive). SUM(NOT NOT positive), , , - .;)
( ), - comments upvotes downvotes. upvotes downvotes, , , MySQL .