[quote=âblackhat, post:1, topic:114146â]Is there a way I can sum the wp_toplist.site_votes too ? like sum(site_votes) where site_id = $id ?[/quote]could you please take a moment and explain exactly which columns you want to return in the query from each table
that dreaded, evil âselect starâ is messing up my understanding of what you want
Well I just used the star cause I was just lazy to write more but this is what I come up with that worked
SELECT *, count(wp_toplist.link_id) AS totalVotes FROM wp_toplist INNER JOIN wp_links ON wp_toplist.link_id=wp_links.link_id GROUP BY wp_toplist.link_id ORDER BY totalVotes DESC
One table contains the link information etc and the other (wp_toplist) takes care of the votes. I guess I could optimize it and remove the star
if youâre gonna persist in using the dreaded, evil âselect starâ along with GROUP BY, please be aware that the values of some of the columns might be misleading