These two queries work:
SELECT
u.id,
u.email,
COUNT(*) as Current
FROM
users u,
rounds cur
WHERE
cur.user = u.id
AND u.email = 'foo@foo.com'
GROUP BY cur.user;
SELECT
u.id,
u.email,
COUNT(*) as old
FROM
users u,
rounds__20120311_010951 old
WHERE
old.user = u.id
AND u.email = 'foo@foo.com'
GROUP BY old.user;
But I really want to do this:
SELECT
u.id,
u.email,
COUNT(old.*) as March11,
COUNT(cur.*) as Current
FROM
users u,
rounds cur,
rounds__20120311_010951 old
WHERE
old.user = u.id
AND cur.user = u.id
AND u.email = 'foo@foo.com'
GROUP BY old.user, cur.user
I think the syntax error is from this COUNT(old.*) but I don’t know for sure.
Is it possible to combine those queries?
Use
GROUP BY u.id, u.email. Then, in your select, useCOUNT(old.id)andCOUNT(cur.id).