T-SQL JOIN

I was viewing a query offline (can't post the fully query here) that contained a JOIN but instead of
having the JOIN condition for the Primary Key =  Foreign key
the syntax was  Primary key LIKE Foreign key.    My question is I have never seen a T-SQL JOIN before like this.
If you have can you give me an example of when you would use LIKE instead of = in a JOIN.
Thanks for the help.
LVL 3
fjkaykr11Asked:
Who is Participating?
 
Anthony PerkinsCommented:
You would use a LIKE when the values were similar.  For example ZIP codes and 3 digit USPS postal codes.  As you may or may not know the USP postal rates for packages greater than 13 oz are determined based on the 3 digit ZIP codes, So your SQL query could look like this (assuming that the USPS had values for ZIPCode3 such as "760%":

FROM ShipAddress s
            USPSZones u on s.ZIPCode LIKE u.ZIPCode3

I am not saying this is a good approach or not, merely giving you an example.  So don't shoot the messenger.
0
 
fjkaykr11Author Commented:
Anthony thank you for the detailed explanation.  I really appreciate it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.