问题
can we always convert a usual subquery/correlated subquery to join type query?
回答1:
yes and no...
Yes, in that JOIN/EXISTS/IN usually give the same plan and are often the same
No, in that if the EXISTS table has > 1 row for the main table you'll need DISTINCT to avoid dupes
I'd stick with an EXISTS type query if this is relevant and you don't need data from the EXISTS table
回答2:
Yes, but it means that what you JOIN to can appear in the result set. A subquery in either an EXISTS or IN clause would not have this risk.
来源:https://stackoverflow.com/questions/2676874/correlated-query-subquery-vs-join-query