所以我试图找出一种方法,将一列的每一行与另一列中的所有行进行比较,并过滤掉与之比较的列中不存在的那些。我了解如何逐行比较两列,如下所示:
select table1.column1
from table1 inner join
table2 on table1.id = table2.id
where column1 <> column2
但我想将 column1 中 table1 的行与 table2 中 column2 的所有行进行比较,并找到 column1 中根本不存在于 column2 中的行。所以它就像具有这些值的列:
Column1 Column2
1 2
2 1
4 3
5 5
7 6
在 SQL 之后,它会变成这样:
Column1
4
7