SQL 存在命令
我有一个想要优化的查询。我想尝试使用“EXISTS”命令,而不是“IN”命令,但每当我尝试实现“EXISTS”时,它都会返回比应有的行数更多的行。
使用“IN”查询:
SELECT count(*)
FROM echosign_devbox.participation as p
left join echosign_devbox.agreement as a
on p.agreement_id=a.agreement_id
where a.status not in ('SIGNED', 'ABANDONED', 'EXPIRED', 'ABANDONED_BEFORE_SEND');
有谁知道我应该如何更改,只是为了使用“EXISTS”命令?谢谢!
I have a query that I want to optimize. I want to try with 'EXISTS' command, instead of 'IN' command, but whenever I try to implement 'EXISTS', it returns more rows than it should.
Query with 'IN':
SELECT count(*)
FROM echosign_devbox.participation as p
left join echosign_devbox.agreement as a
on p.agreement_id=a.agreement_id
where a.status not in ('SIGNED', 'ABANDONED', 'EXPIRED', 'ABANDONED_BEFORE_SEND');
Does anyone know how should I change, just to be with 'EXISTS' command? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

a
需要INDEX(agreement_id, status)
这会给出“正确”答案吗?
表之间有什么关系? 1:1? 1:很多?
a
needsINDEX(agreement_id, status)
Would this give the 'correct' answer?
What is the relationship between the tables? 1:1? 1:many?