I need to create a summary from 3 different tables, 1 parent table, 2 child tables.
How can I get the number of records from two child tables, based on the user id (pk in each of the 3 tables).
Parent table (user) pk is userId
Child tables 1 and 2 have composite pks of userId and webId.
I know this isn’t the proper SQL syntax, but it illustrates what I’m after.
select u.userId, count(table1.webId), count(table2.webId)
from `user` u
left join `table1` t1 on u.userId = t1.userId
left join `table2` t2 on u.userId = t2.userId
group by u.userId
You might need to add
DISTINCT–