SQL选择包含其他列中的值的所有行

时间:2018-03-14 13:42:55

标签: sql

我是SQL的新手。我想选择与“东京”相关的所有“A-No”行。表格和期望的结果如图所示。如果一行包含东京,那么我需要列出所有相关的“否”行。我有两个“东京”值,但我需要根据“A-No”列列出6行。

图片:https://ibb.co/cOFBHx

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

您可以使用inexists

select t.*
from t
where t.a_no in (select t2.a_no from t t2 where t2.b_city = 'Tokyo');
相关问题