【发布时间】:2019-07-11 14:02:49
【问题描述】:
我正在尝试返回子表中所有符合条件的记录的所有行
T1:
1
2
3
4
5
T2:
T.ID Id Value
1 01 Apple
1 02 Banana
2 05 Grapes
2 07 Kiwi
2 08 Apple
3 04 Banana
3 06 Potato
4 10 Honeydew
4 11 Berries
5 14 Apple
5 15 Kiwi
5 16 Radish
我需要识别 T1 中的所有 id,它们是 T2 中的 Fruit,
T2.value in(苹果、葡萄、香蕉、猕猴桃、蜜露、浆果)
期望的输出:
1
2
4
我试过这个:
select t1.id from t1,t2
where t1.id = t2.id
and t2.value in ('Apple','Grapes','Banana','Kiwi','Honeydew','Berries')
但它不返回我需要的输出,它还返回#3&5。
【问题讨论】:
-
你怎么知道哪些值是水果?
-
我会明确搜索这些值。让我在我的问题中添加它
-
您的文字列表中有大小写问题。看起来应该是
('Apple','Grapes','Banana','Kiwi','Honeydew','Berries')。 -
更新了问题