0

I have the following query:

select full_name, email, users.uid
from
cloudsponge
inner join 
`users` on users.uid = cloudsponge.importer_uid
where cloudsponge.email not in (select mail from users)

It works as expected but I'm wondering, can I convert the last line to a join (rather than a subquery). This would be helpful as I can use my frameworks ORM rather than hardcode SQL into the application.

Thanks!

4

1 回答 1

4

你可以写:

SELECT full_name, email, users.uid
  FROM cloudsponge
 INNER
  JOIN users
    ON users.uid = cloudsponge.importer_uid
  LEFT
  JOIN users AS users2
    ON cloudsponge.email = users2.mail
 WHERE users2.mail IS NULL
于 2013-07-05T17:44:04.830 回答