I need to make a query that selects everything from a table A, and in addition to have a column that indicates the number of times that the value of A.col1
is in B.col2
.
Example:
Table A:
id name
1 "y"
2 "z"
3 "w"
Table B:
id name
15 "y"
23 "w"
14 "y"
I want a query that will give me the following:
id name numOfTimes
1 "y" 2 // y is shown twice in table B
2 "z" 0 // z isn't shown in table B
3 "w" 1 // w is shown once in table B