Possible Duplicate:
SQL query with duplicate records
Hi.
I am trying to write a query to return rows from Customer table for multiple orders.
Currently I am writing 2 queries to solve this problem. Is there anyway I can put it in one query?
//Get all customers
select customerID from Customer
//For each customer
select * from Orders where orderID in
(select OrderId from Customer where customerID = 123456)
and success = 1
Here is the table structure
Customer table ----------------------------------------- orderID CustName CustomerID --------------------------------------- 100 test 123456 101 test 123456 Orders table ------------------------------------ pID OrderID Success ----------------------------------- 1 100 1 2 101 1