SELECT COUNT from multiple tables

General discussions related to php

Moderators: macek, egami, gesf

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

Re: SELECT COUNT from multiple tables

Post by seandisanti » 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

Who is online

Users browsing this forum: No registered users and 3 guests