Is a JOIN more/less efficient than EXISTS IN when no data is needed from the second table?
        Posted  
        
            by twpc
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by twpc
        
        
        
        Published on 2010-03-22T12:01:31Z
        Indexed on 
            2010/03/22
            12:11 UTC
        
        
        Read the original article
        Hit count: 175
        
I need to look up all households with orders. I don't care about the data of the order at all, just that it exists.
Is it more efficient to say something like this:
SELECT HouseholdID, LastName, FirstName, Phone 
FROM Households 
INNER JOIN Orders ON Orders.HouseholdID = Households.HouseholdID
or this:
SELECT HouseholdID, LastName, FirstName, Phone 
FROM Households 
WHERE EXISTS 
    (SELECT HouseholdID 
     FROM Orders 
     WHERE Orders.HouseholdID = Households.HouseholdID)
        © Stack Overflow or respective owner