我有一个Fruit
表,如下所示:
名称 | 属性 | 值 | |
---|---|---|---|
苹果 | 价格 | 5美元 | |
苹果 | 颜色 | 红色||
苹果 | 数量 | 20 | |
梨 | 价格 | $5 | |
梨 | 颜色 | Kelly | |
梨 | 重量 | 50g | |
梨 | 质量 | Good |
您可以使用not exists
:
select f.*
from fruit f
where f.name = 'Pear' and
not exists (select 1
from fruit f2
where f2.name = 'Apple' and
f2.property = f.property and
f2.value = f.value
);