[UPHPU] adding a count to an MySQL query

Wade Preston Shearer wadeshearer.lists at me.com
Thu Dec 24 11:53:38 MST 2009


Here, I have whittled the query down to just the essentials:

SELECT even.even_title, (
		SELECT COUNT(meev.meev_id)
		FROM dev_cscca.members_events meev
		WHERE meev.meev_date_scheduled is not NULL
		) as count
FROM dev_cscca.events even


…which returns:

+-------------------------+-------+
| even_title              | count |
+-------------------------+-------+
| First aid certification |     3 |
| 2010 Annual Conference  |     3 |
| CPR Certification       |     3 |
+-------------------------+-------+


I want it to return:

+-------------------------+-------+
| even_title              | count |
+-------------------------+-------+
| First aid certification |    1 |
| 2010 Annual Conference  |    1 |
| CPR Certification       |    1 |
+-------------------------+-------+


…because I only have one person registered for each event.

Here is a pastebin of the tables:

http://stikked.com/view/raw/63799305


More information about the UPHPU mailing list