Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have 3 Tables, A,B and C.
I want to get data in B where B.id is not in A. and this slolution, i have to LeftJoin With the C

I am really confused, please help
Posted

 
Share this answer
 
Comments
id-athul 25-Oct-13 7:09am    
Thanks, but in my case i have to get a temporary data and with this temp data i have to left join a 3rd table
Animesh Datta 25-Oct-13 7:26am    
Hello ,

just check this query . Here first i do inner join in between Table_1 and Table_2. After that i again do inner join in between the out put with Table_3 . and ultimately get one solution .

select d.Id,c.Id , c.Name from (select a.Name , a.Id from Table_1 a inner join Table_2 b on a.Name=b.Name) as c inner join Table_3 d on d.Id=c.Id
id-athul 25-Oct-13 8:07am    
Thanks :)
You have two ways to do this

SQL
Select B.* FROM B
LEFT JOIN A ON A.ID = B.ID
LEFT JOIN C ON C.Column_name = B.Column_name
Where A.ID IS NULL


The Other is

SQL
Select B.* FRom B
LEFT JOIN C ON C.Column_name = B.Column_name
where B.ID NOT IN (SElect A.ID From A)


*Column_name means you need to give column name you are willing to do between B and C
 
Share this answer
 
Comments
id-athul 25-Oct-13 8:07am    
Thanks, It worked for me
coded007 25-Oct-13 8:27am    
Thanks for Instance response
id-athul 28-Oct-13 2:06am    
Youre welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900