the error is right. You even wrote Exists
in your question but in the example code you wrote exist
with no s
on the end. See here for the proper syntax
You need to correlate the outer query with the sub query in the exists
. It doesn't matter what columns you select because by rule they are not allowed to be evaluated (i.e. select *
is fine)
SELECT *
FROM Customers C
WHERE EXISTS (SELECT * FROM Orders where Orders.CustomerID = C.CustomerID);