I'm glad you were able to figure it out. I was having trouble understanding why you needed a not equal relationship, as I would have thought that any given product option would have to have some direct relationship to the product it's an option for. My basis for thinking this was seeing both a product table and a product option table. I would have imagined they would be linked by a ProductID, directly, and unfortunately, while you now have your solution, I'm as confused as I was to begin with. Perhaps that's why you are an "old hand", and I'm still a "grasshopper"...
Here's where my brain went concept-wise in T-SQL:
DECLARE @ProductID int
SET @ProductID = 12345
DECLARE @PRODUCT_TBL TABLE (
ProductID int,
ProductName varchar(25),
Qty_In_Stock bigint,
Product_Cost money(18,2),
Product_Retail money(18,2)
PRIMARY KEY (ProductID)
)
DECLARE @PRODUCT_OPTIONS TABLE (
ProductOptionID int,
ProductID int,
Option_Description varchar(40),
Option_Cost money(18,2),
Option_Retail money(18,2)
PRIMARY KEY (ProductOptionID)
)
SELECT *
FROM @PRODUCT_TBL AS A LEFT OUTER JOIN @PROUDCT_OPTIONS AS B
ON A.ProductID=B.ProductID
WHERE A.ProductID = @ProductID
Clearly, without any INSERTs, this code is concept only. Let me know where my concept went wrong so I can learn from the master. Thanks!
Steve
(aka smunson)
:):):)
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)