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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Outer join

Author  Topic 

maevr
Posting Yak Master

169 Posts

Posted - 2009-11-12 : 02:57:15
I need help creating a join base don the following criteria:
Display rows that match eachother in table1 and table2 (inner join) and matches that exists in table3 that resides in table2.
If no match between table2 and table3 then do not remove row from result.

I have tried the select below but it displays all rows in table2 even those that do not exist in table1.

select
a.id
a.col1
b.id
b.col1
c.id
c.col1
FROM table1 b inner join table2 a on a.id = b.id
left outer join SS_table3 c on a.id = c.id
and b.FormularId = c.FormularId
order by FormularId

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-12 : 03:59:39
I think it is because "and b.FormularId = c.FormularId" in ON-clause.
Try to do it in WHERE-clause instead of ON-clause.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -