M
MSD
Hi,
I'm trying to join two tables so that the result contains all the rows in
table A and matching rows in table B. This is what I mean:
Table A contains 2 fields, CatId and CatName:
CatId CatName
1 Apples
2 Bananas
3 Pears
Table B contains the amounts in each category. Some categories may not be in
table B. For example, table B could look like this:
CatId Amount
1 10
3 20
I would like to create a query that results in:
CatName Amount
Apples 10
Bananas Null
Pears 20
My query is: SELECT CatName, Amount FROM TableA LEFT JOIN TableB ON
(TableA.CatId = TableB.CatID);
My result does not contain a row for Bananas. How can I get ALL the
categories to appear in my result, even if they have no value in TableB?
Thanks very much,
Emma
I'm trying to join two tables so that the result contains all the rows in
table A and matching rows in table B. This is what I mean:
Table A contains 2 fields, CatId and CatName:
CatId CatName
1 Apples
2 Bananas
3 Pears
Table B contains the amounts in each category. Some categories may not be in
table B. For example, table B could look like this:
CatId Amount
1 10
3 20
I would like to create a query that results in:
CatName Amount
Apples 10
Bananas Null
Pears 20
My query is: SELECT CatName, Amount FROM TableA LEFT JOIN TableB ON
(TableA.CatId = TableB.CatID);
My result does not contain a row for Bananas. How can I get ALL the
categories to appear in my result, even if they have no value in TableB?
Thanks very much,
Emma