yeah, that got all messed up 
i find colour coding sometimes helps
Code:
SELECT date_no_time
, SUM(s) AS Sender
, SUM(x) AS Searches
, SUM(l) AS Logins
FROM ( SELECT DATE(`date`) AS date_no_time
, COUNT(*) AS s
, 0 AS x
, 0 AS l
FROM referrals
GROUP
BY date_no_time
UNION ALL
SELECT DATE(`date`) AS date_no_time
, 0
, COUNT(*)
, 0
FROM searches
GROUP
BY date_no_time
UNION ALL
SELECT DATE(`date`) AS date_no_time
, 0
, 0
, COUNT(*)
FROM users
GROUP
BY date_no_time ) AS u
GROUP
BY date_no_time
ORDER
BY date_no_time DESC LIMIT 10
it may also help to visualize the rows produced by the UNION...
Code:
date_no_time s x l
2010-11-14 12 0 0
2010-11-14 0 23 0
2010-11-14 0 0 5
2010-11-15 11 0 0
2010-11-15 0 9 0
2010-11-15 0 0 37
yours was the 3rd SELECT in the UNION, so the 3rd column (blue) in each SELECT
the outer query produces the SUMs of the three rows for each date
Bookmarks