Suppose We have two Tables
Customers and Orders
Customers Table:-
custid custname
------- ---------
1 aaa
2 bbb
3 ccc
Orders Table :-
orderid custid date
-------- ------ -----
101 1 2016-03-01
102 1 2016-03-03
103 2 2016-03-01
Now , we have show customers who have placed no orders
We can do it several ways:-
1.Without Join
Select custid
from Customers
where custid not in
(Select custid from Orders)
and
2.With Join
Select C.custid
from Customers C left join Orders O
on C.custid = O.custid
where O.orderid is null
I was asked will there be any performance difference ?if ,which will do better and why?