SELECT COUNT from multiple tables

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Thu Mar 28, 2013 10:52 pm

you can't aggregate a wildcard like count(*), because you'd not be giving it any group by field. the way to do it would be like this...

SELECT field1, count(field2) as count FROM table where field3='role' GROUP BY field1

substitute in your own field and table names, joins etc, but that's how you get a good count.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests