0

如何使用 EXISTS 而不是 IN 函数优化以下 mysql 查询?

Subscriber.first(:conditions => ["email IN(SELECT email from submissions WHERE url = ? AND confirmed != 0)", url], :order => "RANDOM()")

感谢帮助!

4

1 回答 1

1

基于 sql 语法 for exists

EXISTS (SELECT email from submissions x WHERE url = ? AND confirmed != 0 AND x.email = email)
于 2012-05-16T21:27:24.133 回答