Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Joining two tables matched on one column

Author  Topic 

deanfp
Starting Member

26 Posts

Posted - 2012-03-27 : 06:08:05
Hi

Wonder if someone can help. I have two tables that I am trying to add a column from table 2 to table 1.

Product table contains all products and has a column called ProductID. ProductCategory contains the same ProductID but has a column StoreID that I want to show against a SKU value in Table 1.

This I thought would work but does not seem to. Any ideas where I am going wrong?

SELECT ProductID, SKU FROM Product
LEFT JOIN StoreID FROM ProductCategory
ON Product.ProductID = ProductCategory.ProductID

Thanks!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-03-27 : 06:15:15
select t1.ProductID, t1.SKU, t2.StoreID
from Product as t1
left join ProductCategory as t2 on t2.ProductID = t1.ProductID



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

deanfp
Starting Member

26 Posts

Posted - 2012-03-27 : 06:15:45
It's ok managed to figure it out
Go to Top of Page
   

- Advertisement -