【发布时间】:2010-10-20 03:35:32
【问题描述】:
复制:
我有 2 张桌子:
TABLE1
Table1Id
TABLE2
Table2Id
Table1Id
UserId
TABLE2 中有数千个条目。我想返回一个 TABLE1 条目列表,其中 TABLE2 中没有针对特定用户的条目。因此,TABLE2 中没有外键条目。像这样的查询:
select count(*) from TABLE1 where Table1Id not in (
select Table1Id from TABLE2 where id_user = 1)
但是,该查询运行非常缓慢。获得所需结果的最有效方法是什么?
【问题讨论】:
-
与此处相同:*.com/questions/760950/…