Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi ,Why isn't this piece of code equal to inner joining three tablesI want to have subquery columns in result by changing it to inner joinI use "and" for common columns in "ON" statementbut get differnt result
SELECT * from table1 dd where (dd.c,dd.i) in(select ply.c,rply.i from ply ,rply where rply.s in ('C','K') and ply.f=rply.f and ply.code=rply.code)
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2012-08-14 : 07:57:42
It is not a valid statement at all.
SELECT t.*FROM dbo.Table1 AS tWHERE EXISTS ( SELECT * FROM dbo.Ply AS p INNER JOIN dbo.rPly AS r ON r.f = p.f AND r.Code = p.Code AND r.s IN ('C', 'K') WHERE t.c = p.c AND t.i = r.i )
And not, is not like an inner join, because with inner join you do filter and you can also get multiple rows back.In the query above you do filter but you cannot get multiple rows back.N 56°04'39.26"E 12°55'05.63"