I have a user_id key that shows up in Table A, Table B, Table C.
Table A
User_id value
1 A
2 B
3 C
Table B
User_id value
1 A
1 B
1 C
Table C
User_id value
1 A
1 B
0 C
tA is unique on User_id. I am trying to get the number of occurrences in Table B and Table C with that user_id in one query.
I tried:
SELECT tA.user_id, (SELECT count(*) FROM tB as countB GROUP BY tA.user_id),(SELECT count(*) FROM tC as countC GROUP BY tA.user_id) FROM tA where tA.user_id='1'
I think this is what you’re trying to do: