题目:
- 利用子查询和not in解决。
select name as 'Customers'
from customers
where id not in
(
select customerid from orders
);
select customerid from orders
执行结果如下:
- 利用连接解决。
左连接customers表和orders表。
按照题目要求,筛选出从不购物的即上表中customerid为null的记录。
题目:
select name as 'Customers'
from customers
where id not in
(
select customerid from orders
);
select customerid from orders
执行结果如下: