I have been fiddling with creating my own message board, and though it is working fine I wanted to add post voting to it (diagram at the end of the post).
I pulled the data I wanted from my two tables msgboard_user and msgboard_post like this:
SELECT p.post_id, p.user_id, u.username, get_time_diff(p.date) as date, p.ip, p.text, p.parent_post_id, p.approved AS posts
FROM msgboard_post p, msgboard_user u
WHERE p.user_id = u.user_id
AND p.approved = "yes"
ORDER BY p.date DESC
-- code for limit...
So now I need to be working with a third table, msgboard_vote. Every vote gets one row in the table and I would like to have one column in my result that sums the votes for that post. The vote (vote_value) can be either 1 or -1. Posts that have no vote (no row in msgboard_vote) would preferably be summed up as 0 in the result, null would do it as well.
Been tinkering for several hours… :/
Would greatly appreciate some help on this 🙂

Avoid sub-selects in the selected columns and the WHERE clause, the optimizer doesn’t handle them well.