我正在尝试根据其他表中的 id 排除表中的行。我有 2 个表,其中的“select * from”会生成一个像 (1,2,3) 这样的集合
我正在尝试将这两个子查询的结果合并为一个,例如:
(1,2,3) + (4,5) = (1,2,3,4,5)
所以我可以用“NOT IN (1,2,3,4,5)”过滤大表
我一直在查看 GROUP_CONCAT、UNION 和所有其他类型,但我似乎找不到真正有效的东西。
有人有想法吗?
select *
from Table3
where id not in (
select id from Table1 --your subquery that returns 1,2,3
union all
select id from Table2 --your subquery that returns 4,5
)
select * from mytable
where id not in (
select id from othertable
union
select id from othertable2
)