有产品Product和销售记录Sales两张表
Product :
| product_id | product_name | unit_price |
| 1 | S8 | 1000 |
| 2 | G4 | 800 |
| 3 | iPhone | 1400 |
Sales :
| seller_id | product_id | buyer_id | sale_date | quantity | price |
| 1 | 1 | 1 | 2019-01-21 | 2 | 2000 |
| 1 | 2 | 2 | 2019-02-17 | 1 | 800 |
| 2 | 1 | 3 | 2019-06-02 | 1 | 800 |
| 3 | 3 | 3 | 2019-05-13 | 2 | 2800 |
问题
查找买了S8但没买iPhone的buyer_id
代码
select s.buyer_id,
p.product_name
from Product p,
Sales s
where s.product_id =p.product_id
and p.product_name ='S8'
and not exists(select s.buyer_id,
p.product_name
from Product p,
Sales s
where s.product_id =p.product_id and p.product_name ='iPhone')
错误结果和问题
结果输出为空,我先筛选买了S8的顾客,并且没有买过iPhone,这里用not exists为什么没有生效?