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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HowTo consolidate SQL statements... 1

Status
Not open for further replies.

sqlsamurai

Programmer
May 11, 2005
120
US
How would I consolidate these three statements? The only difference is one of the fields in the WHERE statements. I'm using SQL Server 2005 if that makes any difference.
Code:
SELECT Inventory.*, Products.IjoistTypeID 
FROM Products INNER JOIN Inventory ON Products.ProductID = Inventory.ProductID 
WHERE (((Inventory.PurchaseOrderID)=" & al_MasterID & ") AND ((Products.LumberTypeID)=3))
Code:
SELECT Inventory.*, Products.IjoistTypeID 
FROM Products INNER JOIN Inventory ON Products.ProductID = Inventory.ProductID 
WHERE (((Inventory.ProductionID)=" & al_MasterID & ") AND ((Products.LumberTypeID)=3))
Code:
SELECT Inventory.*, Products.IjoistTypeID 
FROM Products INNER JOIN Inventory ON Products.ProductID = Inventory.ProductID 
WHERE (((Inventory.ReturnID)=" & al_MasterID & ") AND ((Products.LumberTypeID)=3))

Thanks
 
Code:
SELECT Inventory.*, Products.IjoistTypeID
FROM Products INNER JOIN Inventory ON Products.ProductID = Inventory.ProductID
WHERE (Inventory.PurchaseOrderID = al_MasterID  OR
       Inventory.ProductionID    = al_MasterID  OR
       Inventory.ReturnID        = al_MasterID) AND
      (Products.LumberTypeID)=3)
Is that what you want?

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Yes it is... I guess I was making it more complicated that it was. ;-) Star for you.
 
Just saw a typo in my example. Remove closing bracket before equal sign ;-)

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top