Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sql query to add records that share a common productfamilyid

Status
Not open for further replies.

aonefun

Technical User
May 21, 2007
79
US
Some products in my database named "ManufacturerPartNumber" are part of a product family, thus they share a common "ProductFamilyID".
How do I include these additional "ManufacturerPartNumber" fields that share a common ProductFamilyID in the query as follows:

SELECT ManufacturerPartNumber, ProductFamilyID
FROM Products
WHERE ManufacturerPartNumber = Request.Form("VendorPartNumber")OR
ManufacturerParNumber [this is where I am stuck]
 
If I'm reading your requirements correctly then a subquery should do the trick.
Code:
SELECT Products.ManufacturerPartNumber, Products.ProductFamilyID
FROM Products
WHERE ManufacturerPartNumber = Request.Form("VendorPartNumber")
   OR ProductFamilyId IN (SELECT ProductFamilyID FROM Products WHERE WHERE ManufacturerPartNumber = Request.Form("VendorPartNumber"))

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
thank you for your response. Can you please phrase this portion of the query in psuedocode (plain english)

"OR ProductFamilyId IN"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top