MYSQL对不为空的行进行计数
我只需要数那些不是空的行。谢谢MYSQL对不为空的行进行计数,mysql,Mysql,我只需要数那些不是空的行。谢谢 SELECT component,count(comp_details) FROM table GROUP BY component 尝试这样做:根据需求添加where子句 SELECT component,count(comp_details) FROM table GROUP BY component SELECT component,count(comp_details) FROM table where comp_details is not null
SELECT component,count(comp_details) FROM table GROUP BY component
尝试这样做:根据需求添加where子句
SELECT component,count(comp_details) FROM table GROUP BY component
SELECT component,count(comp_details) FROM table where comp_details is not null and comp_details != "" GROUP BY component
虽然您希望有条件地计数,但您的查询没有任何
WHERE
部分
SELECT component,count(comp_details) FROM table GROUP BY component
SELECT component,count(comp_details)
FROM table
WHERE IFNULL(component, '') != ''
GROUP BY component
comp_details是否可以为null?它不应该是
comp_details不为null且comp_details!=“
?