diff admajax.php @ 545:d5ac0521ca16

Possibly fix a query to work with Postgresql.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 16 Dec 2013 00:27:43 +0200
parents b4581dc165dc
children f1f55db4228f
line wrap: on
line diff
--- a/admajax.php	Sun Dec 15 23:57:05 2013 +0200
+++ b/admajax.php	Mon Dec 16 00:27:43 2013 +0200
@@ -940,9 +940,9 @@
 
         $sql =
           "SELECT compos.*, ".
-          "(SELECT COUNT(*) FROM entries WHERE compo_id=compos.id) AS nentries ".
-          "FROM compos WHERE nentries > 0 ".
-          "ORDER BY id DESC";
+          "COUNT(DISTINCT entries.id) AS nentries ".
+          "FROM compos LEFT JOIN entries ON compos.id=entries.compo_id ".
+          "GROUP BY compos.id HAVING COUNT(DISTINCT entries.id) > 0 ORDER BY compos.id DESC";
 
         $currCompoID = stGetDisplayVar("compoID");
         if (($res = stExecSQL($sql)) !== false)