I have the following table called votes:
I'm trying to join a list of items, with a users table, and this votes table.
SELECT list_items.item_id, text, date_added, username
FROM list_items
NATURAL JOIN users, votes
WHERE list_id = 3
That query is giving me this:
I would like to get a total vote count for each list_item, as well a column for up_votes
and another for down_votes
. And, of course, I don't want the item_id's to repeat like that.
I tried combining SUM with IF as explained in a Nettuts+ video, but the tutorial was too simple.
EDIT: Here's the list_items table:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…