Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I'm sure there is a simple answer to this but I just dont know. In my products table i have FirstOptionID and SecondOptionID, but joined to the ProductOptions table. How do I return the name for the FirstOptionName and the SecondOptionName? ThanksSELECTProducts.ProductID,??FirstOptionName??,??SecondOptionName??,Products.FinalPriceFROM ProductOptions INNER JOINProducts ON ProductOptions.OptionID = Products.FirstOptionID AND ProductOptions.OptionID = Products.SecondOptionID
r937
Posting Yak Master
112 Posts
Posted - 2002-08-13 : 18:21:59
you need to join to the options table twice
SELECT Products.ProductID, , o1.OptionName as FirstOptionName , o2.OptionName as SecondOptionName , Products.FinalPrice FROM Products INNER JOIN ProductOptions o1 ON o1.OptionID = Products.FirstOptionID INNER JOIN ProductOptions o2 ON o2.OptionID = Products.SecondOptionID