Andrew McComb Andrew McComb - 1 year ago 53
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download