EnjoY | Database Research And Development: SQL Server: Never Apply INNER JOIN or EQUI JOIN on NULL Values

Friday, September 4, 2020

SQL Server: Never Apply INNER JOIN or EQUI JOIN on NULL Values

 

Sharing the truth about NULL Values when we using an INNER JOIN or EQUI JOIN of SQL Server. Only a few of the good DB Developers know all the truth behind the NULL.

I already shared a couple of articles on NULL. When we are joining two NULL values, we can’t get any result out of it because NULL is not a value which is just an empty identifier. So try to avoid NULL columns in the INNER JOIN or EQUI JOIN or you can add IS NOT NULL condition.

Please check below few samples:
Create sample tables:

NULL = NULL: No result

RIGHT OUTER NULL: All records NULL

Join on ID: Expected Result

LEFT OUTER NULL: Expected Result of for tbl_a1

No comments:

Post a Comment

It’s all about friendly conversation here at small review :) I’d love to be hear your thoughts!

Be sure to check back again because I do make every effort to reply to your comments here.

Featured Post

SQL Server : SELECT all columns to be good or bad in database system

This article is half-done without your Comment! *** Please share your thoughts via Comment *** In this post, I am going to write about one o...

Popular Posts