MySQL select count -


I am trying to calculate the number of companies with at least one product from the following query < Pre> SELECT count (*) from company.c zone product page c.id = product.company_id WHERE p.is_deleted = 0 and c.is_customer = 1 and c.company_type_id = 5 GROUP by c.id

Therefore, it shows me the list of all companies and count of products for each company.

What am I trying to achieve, the companies count from the top. / P>

It can be obtained as follows:

  SELECT count (*) FROM (SELECT count (*) to Company See Product Product page at c.id = product.company_id WHERE P.is_deleted = 0 and c.is_customer = 1 and c.company_type_id = 5 GROUP by c.id) AS t1   

Therefore, it gives me the right result, but I just thinking If I have any more efficient way of doing things.

I believe you can simplify it on:

 CAD = Producer's page. WHERE p.is_deleted = 0 and c.is_customer = 1 and c.company_type_id = 5    

Comments