aaron.reese (6/19/2013)
you will get an error message
Select Customer.CustomerID from salesorder
table Customer has not been defined in the subquery.
Are you sure? Check this
CREATE TABLE customer
(
customerid INT
)
CREATE TABLE salesorder
(
customerid INT
)
INSERTcustomer
SELECT1 UNION ALL
SELECT2
INSERTsalesorder
SELECT1
SELECT * FROM customer WHERE customer.customerid IN (SELECT customer.customerid FROM salesorder)
DROP TABLEcustomer
DROP TABLEsalesorder
The query will return all the rows from the customer table
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/