Total PageViews

Thursday, July 25, 2019

DIFFERENCE B/W INNER JOIN AND INTERSECT OPERATOR

Suppose you have two tables and you want the distinct rows which are common in both the tables what will you do to get them? Most of us will answer that they will use INNER JOIN to get the common rows of two tables, right?     Wrong!!!!!!

This is a big misconception that INNER JOIN will always return all the common rows between two tables. In reality, "INNER JOIN treats two NULLS as two different values rather than a same value" so if you are joining a row based on a NULLable column there is a chance that if both tables have NULLs in that column then INNER JOIN will ignore those rows because

"Two NULLs are not same in TSQL"

No comments:

Post a Comment