Andrew McComb Andrew McComb - 3 months ago 5x
SQL Question

Why is it necessary to join on multiple columns SQL?

In a general sense in SQL joins, what is the benefit to joining tables with multiple versus one column?


It depends on the structure of your data. One column may not be enough to properly identify matching rows.

Consider joining on Address data (as an example). If you only join on the Address line, but not City/State, you might have rows match to both

123 Front St, New York City, NY  


123 Front St, Los Angeles, CA  

even though your person only lives in one place.

side note: joining on address lines probably means your database needs normalizing. I use it as an example only