MySQL Forums
Forum List  »  PHP

Re: select statement with count
Posted by: Peter Brawley
Date: November 09, 2019 10:20AM

Is this what you mean? ...

select users.name, ifnull(x.N,0) as theCount
from users
join (
  select userid, count(*) as N
  from userdocs
  group by userid
) as x on users.id=userdocs.userid;

Options: ReplyQuote


Subject
Written By
Posted
November 09, 2019 07:50AM
Re: select statement with count
November 09, 2019 10:20AM
November 09, 2019 10:49AM
November 09, 2019 11:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.