From 58c99266475291ee2f3963c9b75dc46dabea67ab Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Mon, 26 Aug 2002 18:25:05 +0000 Subject: [PATCH] - Another "SELECT... LEFT JOIN... GROUP BY... ORDER BY" by James. --- modules/poll.module | 2 +- modules/poll/poll.module | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/poll.module b/modules/poll.module index 6a47fe451119..5869a0e4d444 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -216,7 +216,7 @@ function poll_page() { global $theme; $theme->header(); - $result = db_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM node n LEFT JOIN poll p ON n.nid=p.nid LEFT JOIN poll_choices c ON n.nid=c.nid WHERE type='poll' AND status='1' AND moderate='0' GROUP BY n.nid, n.title, p.active ORDER BY n.created DESC"); + $result = db_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM node n LEFT JOIN poll p ON n.nid=p.nid LEFT JOIN poll_choices c ON n.nid=c.nid WHERE type = 'poll' AND status = '1' AND moderate = '0' GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC"); $output = "<ul>"; while ($node = db_fetch_object($result)) { $output .= "<li>". l($node->title, array("id" => $node->nid)) ." - ". format_plural($node->votes, "vote", "votes") ." - ". ($node->active ? t("open") : t("closed")) ."</li>"; diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 6a47fe451119..5869a0e4d444 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -216,7 +216,7 @@ function poll_page() { global $theme; $theme->header(); - $result = db_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM node n LEFT JOIN poll p ON n.nid=p.nid LEFT JOIN poll_choices c ON n.nid=c.nid WHERE type='poll' AND status='1' AND moderate='0' GROUP BY n.nid, n.title, p.active ORDER BY n.created DESC"); + $result = db_query("SELECT n.nid, n.title, p.active, SUM(c.chvotes) AS votes FROM node n LEFT JOIN poll p ON n.nid=p.nid LEFT JOIN poll_choices c ON n.nid=c.nid WHERE type = 'poll' AND status = '1' AND moderate = '0' GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC"); $output = "<ul>"; while ($node = db_fetch_object($result)) { $output .= "<li>". l($node->title, array("id" => $node->nid)) ." - ". format_plural($node->votes, "vote", "votes") ." - ". ($node->active ? t("open") : t("closed")) ."</li>"; -- GitLab