Here is my mysql query below. Through many helpful questions and comments, I am almost at the end of my journey. The idea of ββthis request is that the user sends a link, the application inserts two lines, one into the links and the other into the votes (default vote, why not vote for your own submission?). Then each vote is another row in the votes table with either a karma_upor karma_downequal to 1 (will be changed to soon karma_deltato save an extra column. I also have a popularity algorithm that seems to b0rking my request. Below the request guarantees me this a mistake.
#1247 - Reference 'karma' not supported (reference to group function)
The whole point of most of this request is to get karma
SELECT links.*, (SUM(votes.karma_up) - SUM(votes.karma_down)) AS karma
FROM links, votes
WHERE links.id = votes.link_id
GROUP BY votes.link_id
ORDER BY (karma - 1) / POW((TIMESTAMPDIFF(HOUR, links.created, NOW()) + 2), 1.5) DESC
LIMIT 0, 100
ORDER BY , votes .
anonymous