Revision: 31665
Updated Code
at October 8, 2010 06:12 by jbranca
Updated Code
SELECT DISTINCT g.gallery_name, g.gallery_id, count(g.gallery_id) AS sum FROM galleries AS g JOIN images AS i ON g.gallery_id = i.gallery_id GROUP BY g.gallery_id ORDER BY sum ASC
Revision: 31664
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 10, 2010 06:09 by jbranca
Initial Code
SELECT DISTINCT g.gallery, g.nid, count(g.nid) AS sum FROM galleries AS g JOIN images ON g.nid = images.gallery GROUP BY g.nid ORDER BY sum ASC
Initial URL
count-of-joined-records
Initial Description
You have two tables galleries and images, and you need to know how many images each gallery has associated with it. This Query returns the sum of distinct record joined to another table by a common field (gallery_id).
Initial Title
Number of records in one table of a type from another table.
Initial Tags
mysql
Initial Language
MySQL