select
*
from
department as a
left join F_Department as b on a.depid=b.F_depid
where
a.depid is nulldepid,F_depid 建立索引
*
from
department as a
left join F_Department as b on a.depid=b.F_depid
where
a.depid is nulldepid,F_depid 建立索引
SELECT * FROM department as a
WHERE not exists(SELECT * FROM F_Department as b where a.depid = b.F_depid)
not exists也不会走索引的。一楼的方法可以试试