All Forums Database
ylai20 4 posts Joined 09/09
25 May 2016
Left join and filter NULL doesnt work!

Hi, i have 2 tables
Table 1
colA colB colC
A1 A2 A3
B1 B2 B3
Table 2
colA colB colC
A1 C2 C3
D1 D2 D3
Table 1 left jon Table 2 on colA
colA colB colC colAA colBB colCC
A1 A2 A3 A1 C2 C3
B1 B2 B3 ? ? ?
But when I want to filter out the colAA that is null, it doesnt work. The result is still return the same. The result that i wanted is only first row is return.
select * from table 1 a
left join table 2 b on a.colA = b.colA
where b.colAA is not null
Anything wrong with my code?

sakthikrr 53 posts Joined 07/12
26 May 2016

Your query should not return NULL record:

select * from table1 a
left join table2 b on a.colA = b.colA
where b.colA is not null



ToddAWalter 316 posts Joined 10/11
26 May 2016

Please provide the query, results, explain and database release.

dnoeth 4628 posts Joined 11/04
26 May 2016

Your query should work as expected.
But if you want to remove NULLs in table2, why don't you use an Inner Join instead?


You must sign in to leave a comment.