Hi wondering if perhaps someone could shed some light on the below error. The sql works fine locally but i get the the below error remotely.
SQL query:
SELECT COUNT(node.nid),
node.nid AS nid,
node_data_field_update_date.field_update_date_value AS node_data_field_update_date_field_update_date_value
FROM node node
LEFT JOIN content_type_update node_data_field_update_date ON node.vid = node_data_field_update_date.vid
WHERE node.type IN ('update')
ORDER BY node_data_field_update_date_field_update_date_value DESC
MySQL said:
#1140 – Mixing of GROUP columns (MIN(),MAX(),COUNT(),…) with no
GROUP columns is illegal if there is
no GROUP BY clause`
The reason a single column using an aggregate function works while the version with columns not using aggregate functions doesn’t is because you need to specify a
GROUP BYclause. Here’s what your query should look resemble:I changed out your table aliases for shorter ones – easier to read. Here’s the meat of your issue:
I altered the example to use a fake column in order to highlight how the GROUP BY needs to be defined. Any column you reference without wrapping in an aggregate function should to be mentioned in the
GROUP BY. I say should because MySQL is the only db I’m aware of that supports aGROUP BYwhere you can selectively omit columns – there are numerous SO questions about why queries work on MySQL but can’t be ported without change to other dbs. Apparently in your case, you still need to define at least one.