-
Notifications
You must be signed in to change notification settings - Fork 2
Description
php8, mysql 5.7.32
PHP Fatal error: 1055: Expression 5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'MYDB.rd.languages_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by :: SELECT r.products_id, MAX(r.date_added) AS date_added, MAX(r.last_modified) AS last_modified, GREATEST(MAX(r.date_added), IFNULL(MAX(r.last_modified), '0001-01-01 00:00:00')) AS last_date, rd.languages_id
FROM reviews r
LEFT JOIN reviews_description rd ON (r.reviews_id = rd.reviews_id),
products p
WHERE p.products_id=r.products_id
AND p.products_status=1
AND r.status = 1
AND rd.languages_id IN (1,2)
GROUP BY r.products_id ORDER BY last_date DESC
Fixed by adding , rd.languages_id to GROUP BY clause:
$sql = "SELECT r.products_id, MAX(r.date_added) AS date_added, MAX(r.last_modified) AS last_modified, GREATEST(MAX(r.date_added), IFNULL(MAX(r.last_modified), '0001-01-01 00:00:00')) AS last_date, rd.languages_id FROM " . TABLE_REVIEWS . " r LEFT JOIN " . TABLE_REVIEWS_DESCRIPTION . " rd ON (r.reviews_id = rd.reviews_id), " . TABLE_PRODUCTS . " p WHERE p.products_id=r.products_id AND p.products_status=1 AND r.status = 1 AND rd.languages_id IN (" . $sitemapXML->getLanguagesIDs() . ") GROUP BY r.products_id, rd.languages_id" . (SITEMAPXML_PRODUCTS_REVIEWS_ORDERBY != '' ? " ORDER BY " . SITEMAPXML_PRODUCTS_REVIEWS_ORDERBY : '');