difference between where and nested queries

Posted by Chris H on Stack Overflow See other posts from Stack Overflow or by Chris H
Published on 2010-04-15T23:21:23Z Indexed on 2010/04/15 23:33 UTC
Read the original article Hit count: 133

Filed under:

I'm not able to figure out the difference between these queries. I'm pretty sure that the first one is an equi-join. I'm not sure how the second one ISN'T the same as the first. The sub query in #2 selects all Ids from S, and then it returns all R's that also have those ID's, no?

SELECT R.cname FROM R, S, WHERE R.Id = S.Id

SELECT R.cname FROM R WHERE R.Id IN (SELECT S.Id FROM S)

© Stack Overflow or respective owner

Related posts about sql