Monday, 9 September 2013

How to join 2 MySql tables

How to join 2 MySql tables

I have 2 tables. Table1 contains products inventory in store #1 and Table2
contains products inventory in store #2
Table1:
upc | description | QtyOnHand1
4050 | cantaloupe | 10
4131 | fuji apples | 20
5033 | strawberries | 5
Table2
upc | description | QtyOnHand2
4050 | cantaloupe | 15
4131 | fuji apples | 23
4121 | aprictos | 13
What select statement should I use to get the following result.
upc | description | QtyOnHand1 | QtyOnHand2
4050 | cantaloupe | 10 | 15
4131 | fuji apples | 20 | 23
5033 | strawberries | 5 | null
4121 | apricots | null | 13

No comments:

Post a Comment