开发者

get number of users of different type

开发者 https://www.devze.com 2023-02-16 06:19 出处:网络
I got table Users with field type = enum(\'admin\', \'editor\', \'regular\'). how can i get number of admins, editors and regular users in one query?

I got table Users with field type = enum('admin', 'editor', 'regular').

how can i get number of admins, editors and regular users in one query?

My solution was in 3 queries like: SELECT COUNT(*) FROM us开发者_如何学运维ers WHERE type='admin'


using group by

SELECT COUNT(*) as count ,type FROM users  group by type
0

精彩评论

暂无评论...
验证码 换一张
取 消