On MariaDB with ONLY_FULL_GROUP_BY
option enabled, I am getting the error
Non-grouping field 'vcount' is used in HAVING clause
when executing the query
SELECT c.* FROM
automobile_company c
LEFT OUTER JOIN (SELECT company_id, COUNT(*) AS vcount FROM automobile_variant GROUP BY company_id) vc
USING (company_id)
WHERE c.automobile_type = 0 AND vc.vcount > 0;
But the query does not even have a HAVING
clause.
- Is it because MariaDB is rewriting the query for optimization?
- Is it possible to rewrite the above query without moving the GROUP BY outside the sub query?
- Is my only option to use a simple LEFT OUTER JOIN without sub query, and mention every field that needs to be selected in the GROUP BY clause?
optimizer_switch='condition_pushdown_for_derived=off'
. Please file a bug report at jira.mariadb.org.