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.
| Author |
Topic |
|
deanfp
Starting Member
26 Posts |
Posted - 2012-03-26 : 11:28:26
|
| HiI have a product table that lists all Product ID's from our database against a master Code. Some of these Product ID's are mapped to categories which is stored in another table. So what I have isTable 1ProductID (Full List)SKU (Full List)Table 2ProductID (partial list of those products mapped to a category)What SQL Script will be able to join these so that I can extract ProductID and SKU for only those ProdcutID mapped to a category?It's basically mapping two columns from to tables. |
|
|
deanfp
Starting Member
26 Posts |
Posted - 2012-03-26 : 11:33:49
|
| I was thinking something like SELECT ProductID,SKU FROM Product WHERE ProductID IS NOT NULL FROM ProductCategory |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-26 : 11:40:04
|
The INNER JOIN will return only rows which have a match in the second table:select t1.ProductID, t1.SKUfrom Table1 as t1inner join Table2 as t2 on t2.ProductID = t1.ProductID No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
deanfp
Starting Member
26 Posts |
Posted - 2012-03-26 : 11:52:58
|
| Thanks! Worked great |
 |
|
|
|
|
|