sql - MySQL - "Most social User" with the most comments in multiple tables -


i have 2 tables of concern - 'videocomments', 'storycomments'.

i need find 'posterid' has entries in videocomments , storycomments. here's code have far, calls videocomments:

$sql = "select (select posterid                    videocomments                group posterid                order count(posterid) desc limit 1) ) mostsocialuser "; 

how pull , compare count of posterid both tables?

use:

   select x.posterid,           count(y.posterid) + count(z.posterid) numcomments      (select vc.posterid              videocomments vc            union             select sc.posterid              storycomments sc) x left join videocomments y on y.posterid = x.posterid left join storycomments z on z.posterid = x.posterid  group x.posterid  order numcomments desc     limit 1 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -