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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -