Created
May 4, 2013 23:47
-
-
Save lordmatt/5519190 to your computer and use it in GitHub Desktop.
This is an SQL query that will return both the NucleusCMS comment but also the ModComment values all in one hit. This is as part of a side project to make certain comment related functions more sophisticated.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT nucleus_comment.*,count(recordID) as votes,sum(score) as score, TopScore | |
FROM nucleus_comment | |
INNER JOIN nucleus_plugin_modcomments | |
ON nucleus_plugin_modcomments.commentid=nucleus_comment.cnumber | |
INNER JOIN | |
( | |
SELECT * | |
FROM ( | |
SELECT commentid, COUNT( recordid ) AS freq, score AS TopScore | |
FROM nucleus_plugin_modcomments | |
GROUP BY commentid, score | |
) AS FR1 | |
GROUP BY commentid, TopScore | |
HAVING freq = MAX( freq ) | |
) AS T1 | |
ON T1.commentid=nucleus_comment.cnumber | |
GROUP BY nucleus_comment.cnumber |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment