Connecting Tech Pros Worldwide Help | Site Map

sql statement writing

Site Addict
 
Join Date: Feb 2007
Posts: 553
#1: Jun 30 '09
Hi

I have following SQL Queries. Is there a way to to write a single query instead somehow instead?

-Get OrderID from this query
SELECT OrderID FROM Orders WHERE CustomerID='" + reader.Item("CustomerID")


-Using OrderID, get ProductID
"SELECT ProductID FROM OrderDetails WHERE OrderID=" + readerp.Item("OrderID")

-Using ProductID, get Products
SELECT ProductName FROM Products WHERE ProductID=" + reader1.Item("ProductID")

My question is instead of quering three times, can i write a single SQL statemnt to get the final result - (ProductName)

Thanks
Qi
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Jun 30 '09

re: sql statement writing


Yes, use JOIN.

Happy coding !

--- CK
Reply

Tags
sql statement