我有一张最难的桌子
One Two
apple orange
orange grapes
banana strawberry
orange strawberry
grapes apple
现在你可以看到我在这里列出了 5 对。让我告诉你,这不是一张普通的桌子,因为在这张桌子上,水果的名字(苹果)有时在第一列,有时在第二列。
And another table Description
name color
apple red
orange orange
strawberry pink
banana yellow
grapes black
假设我是香蕉,我不想看到与我配对的水果的描述。 现在有人可以告诉我如何在mysql中显示与以下所有内容配对但不与香蕉配对的水果的详细信息:草莓、葡萄、苹果。
我说的是 mysql 不支持的方法。
Select * from description
natural join (select one as name where two='apple' union select two as name where one='apple') as t1
natural join (select one as name where two='grapes' union select two as name where one='grapes') as t2
natural join (select one as name where two='strawberry' union select two as name where one='strawberry') as t3
MINUS
Select * from description
natural join (select one as name where two='banana' union select two as name where one='banana') as b6