表格结构:
CREATE TABLE `blogs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`blog` text,
`status` enum('published','draft','trash') DEFAULT NULL,
PRIMARY KEY (`id`)
)
想要查询显示结果如下:
published draft trash
-----------------------------
3 5 1
-----------------------------
答案 0 :(得分:2)
select sum(status = 'published') as published,
sum(status = 'draft') as draft,
sum(status = 'trash') as trash
from blogs