php - Mysql: Count(*) fields but display greater value first -
i developing comment section parent comments likes show before parent comments no likes or dislikes, in order. similar how answers displayed on stackoverflow, answers votes shown before answers down votes, though votes counted , displayed side of answer. how done correctly?
i have 2 tables: comment (holds comments), opine (holds likes) here's have far:
select comment.*, count(opine.opinion) opinion comment left join opine on comment.comment_id = opine.comment_id comment.parent = 0 order opinion desc
you need group by statement group result-set 1 or more columns. below answer problem.
select comment.*, count(opine.opinion) opinion comment join opine on comment.comment_id = opine.comment_id comment.parent = 0 group comment.comment_id order opinion desc
Comments
Post a Comment