mysql查询根据计数选择行(mysql query to select rows based on count)
我有这个数据库
我想选择options_e,如果它有小于4的选项,或者类似的东西
SELECT * FROM `options` WHERE count(qid) <4这样它将返回小于4的选项的结果。但是当我运行查询时,它在phpmyadmin上表示无效使用组函数。 为什么我会收到此错误? 我可以解决这个问题?
i have this database
i want to select options_e if it has options less than 4, or something like this
SELECT * FROM `options` WHERE count(qid) <4so that it will return the result of options who are less than 4. but on phpmyadmin when i run the query, it says invalid use of group function. why do I get this error? who can i fix this?
最满意答案
你可以尝试这样的:
SELECT options_e, options_f, options_p, options_a, options_s FROM `options` GROUP BY options_e, options_f, options_p, options_a, options_s HAVING count(qid) < 4You can try like this:
SELECT options_e, options_f, options_p, options_a, options_s FROM `options` GROUP BY options_e, options_f, options_p, options_a, options_s HAVING count(qid) < 4更多推荐
发布评论