Connecting Tech Pros Worldwide Help | Site Map

sql statement writing

  #1  
Old June 30th, 2009, 01:02 PM
Site Addict
 
Join Date: Feb 2007
Posts: 553
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
  #2  
Old June 30th, 2009, 09:09 PM
ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,914
Provided Answers: 1

re: sql statement writing


Yes, use JOIN.

Happy coding !

--- CK
Reply

Tags
sql statement


Similar Threads
Thread Thread Starter Forum Replies Last Post
sql statement writing questionit answers 2 July 17th, 2009 02:17 PM
ASP.NET with VB.NET sql statement for MS ACCESS josephrthomas answers 5 November 18th, 2005 02:07 AM
Help needed : How to Execute a string SQL statement with DB2 Doohan W. answers 6 November 12th, 2005 09:00 AM
Need help with SQL statement! Alex answers 7 July 20th, 2005 01:59 AM