我对此 Sql 有一个改进问题:
select
A.id,
...
from
pub_log A
where
1 = 1
and A.scope >= 2
and A.exeby >= 2
and A.executioner not in (
select
B.executioner
from
pub_log B
where
A.executioner in (
'somename'
)
and (
A.scope = 0
or A.scope = 2
)
)
order by
A.create_date desc limit 20 offset 0
我在 PostgreSQL 中使用,在这个查询中我在同一个表上的一个选择中查询了两次 在操作中,这是浪费 那么我该如何改进这个 sql?
你好,
您不能真正以这种方式改进查询 2 次查询同一个表。您需要子查询,因为您没有获得有关刽子手的信息。
希望你的问题是正确的:-) 抱歉伦敦不好
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句