Let's assume I have three tables, such as:
Table A
id | id_b | id_c
-----------------
1 | 1 | 2
2 | 2 | 1
3 | 1 | 2
4 | 2 | 3
5 | 3 | 3
6 | 2 | 1
Table B
id | name
-----------------
1 | 'One'
2 | 'Two'
3 | 'Three'
Table C
id | name
-----------------
1 | 'Alpha'
2 | 'Beta'
3 | 'Charlie'
What I need, is a count of table A on the different pairs of table B and table C, which in this example looks like this:
Result
B | C | count(table_a)
-------------------------------------
'One' | 'Alpha' | 0
'One' | 'Beta' | 2
'One' | 'Charlie' | 0
'Two' | 'Alpha' | 2
'Two' | 'Beta' | 0
'Two' | 'Charlie' | 1
'Three' | 'Alpha' | 0
'Three' | 'Beta' | 0
'Three' | 'Charlie' | 1
I managed to display the rows with non-zeros, but I cannot display the others. Thank you in advance for your help!