By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,266 Members | 1,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,266 IT Pros & Developers. It's quick & easy.

sql statement writing

100+
P: 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
Jun 30 '09 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
Yes, use JOIN.

Happy coding !

--- CK
Jun 30 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.