开发者

get number of users of different type

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜