Does it make sense to replace sub-queries by join?

Posted by Roman on Stack Overflow See other posts from Stack Overflow or by Roman
Published on 2010-12-23T15:18:43Z Indexed on 2010/12/23 15:54 UTC
Read the original article Hit count: 118

Filed under:
|
|
|
|

For example I have a query like that.

select col1 from t1 where col2>0 and col1 in (select col1 from t2 where col2>0)

As far as I understand, I can replace it by the following query:

select t1.col1 from t1
join (select col1 from t2 where col2>0) as t2
on t1.col1=t2.col1
where t1.col2>0

ADDED

In some answers I see join in other inner join. Are both right? Or they are even identical?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about optimization