sql statement writing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • questionit
    Contributor
    • Feb 2007
    • 553

    sql statement writing

    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("Cu stomerID")


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

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

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

    Thanks
    Qi
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Yes, use JOIN.

    Happy coding !

    --- CK

    Comment

    Working...