From b99cbd1d893ff0a730ab7187f409bcdf3c6f4aeb Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" <> Date: Wed, 16 Mar 2005 08:27:14 +0000 Subject: Bug 174295: ANSI SQL requires all columns in SELECT to be in GROUP BY, unless they are in "aggregate" functions Patch By Tomas Kopal r=joel, a=myk --- editclassifications.cgi | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'editclassifications.cgi') diff --git a/editclassifications.cgi b/editclassifications.cgi index 1a1e48026..0e8ffde99 100755 --- a/editclassifications.cgi +++ b/editclassifications.cgi @@ -111,12 +111,15 @@ unless ($action) { # - must use "group by classifications.id" instead of # products.classification_id. Otherwise it won't look for all # classification ids, just the ones used by the products. - my $sth = $dbh->prepare("SELECT classifications.id,classifications.name, + my $sth = $dbh->prepare("SELECT classifications.id, classifications.name, classifications.description, - COUNT(classification_id) as total + COUNT(classification_id) AS total FROM classifications - LEFT JOIN products ON classifications.id=products.classification_id - GROUP BY classifications.id + LEFT JOIN products + ON classifications.id = products.classification_id + " . $dbh->sql_group_by('classifications.id', + 'classifications.name, + classifications.description') . " ORDER BY name"); $sth->execute(); while (my ($id,$classification,$description,$total) = $sth->fetchrow_array()) { -- cgit v1.2.3-24-g4f1b