Mailinglisten-Archive |
Norbert Pfeiffer schrieb: > Hi Sebastian, > >> du wolltest ALLE Technken und dazu die Anzohl der Objekte? >> dann ist das deine Lösung: >> SELECT techniken.*, >> COUNT(objects.*) AS object_count >> FROM techniken >> LEFT JOIN objects >> liefert dir definitiv ALLE techniken! > leider nicht: > > SELECT techniken.tID AS t, techniken.descr AS d, COUNT(*) AS x > FROM techniken > LEFT JOIN objects ON techniken.tID = objects.tID > GROUP BY objects.tID > ORDER BY techniken.descr; > liefert: > +---+--------------+----+ > | t | d | x | > +---+--------------+----+ > | 2 | Holzschnitt | 12 | > | 7 | Mischtechnik | 8 | > | 1 | Radierung | 2 | > +---+--------------+----+ > 3 rows in set (0.00 sec) > > SELECT techniken.tID AS t, techniken.descr AS d, COUNT(*) AS x > FROM objects > LEFT JOIN techniken ON techniken.tID = objects.tID > GROUP BY objects.tID > ORDER BY techniken.descr; > liefert: > +------+--------------+---+ > | t | d | x | > +------+--------------+---+ > | NULL | NULL | 3 | > | 7 | Mischtechnik | 8 | > | 1 | Radierung | 2 | > +------+--------------+---+ > 3 rows in set (0.00 sec) ok, nimm meine Hand ... ;-) SELECT techniken.tID AS t, techniken.descr AS d, COUNT(objects.tID) AS x FROM techniken LEFT JOIN objects ON techniken.tID = objects.tID GROUP BY techniken.tID ORDER BY techniken.descr; -- Sebastian Mendel www.sebastianmendel.de www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet -- Infos zur Mailingliste, zur Teilnahme und zum An- und Abmelden unter -->> http://www.4t2.com/mysql
php::bar PHP Wiki - Listenarchive