Hi,
Given the query below (courtesy of roga)
Code:
SELECT *
FROM logins
LEFT JOIN profiles USING (some_id)
LEFT JOIN prefs USING (some_id)
LEFT JOIN avatars ON profiles.avatar_id=avatars.avatar_id
LEFT JOIN groups ON profiles.group_id=groups.group_id
LEFT JOIN tmpl ON prefs.tmpl_id=tmpl.tmpl_id
WHERE username='john'
I would like to add another clause to the query to count the number of rows from another table given certain conditions. On it's own, that new query looks like this:
Code:
SELECT COUNT(*) FROM message where username=sender
How do I append that to the group of LEFT JOINs query above? The COUNT(*) should only apply to the query on the 'message' table and not only the other tables.