title: Matching First and Last Name on two different tables
body: <p>I am trying to match the first name varchar (50) and last name varchar(50) from table A to the first name varchar(50) and last name varchar(50) on table B. The issue is that both table contain a lot of shortened first names like the name Andrew in table A and there might be a matching record with the last name but the first name is Andy so it comes up as not a match. Is there anyway to get around this in SQL. The shortened names is a vice verse problem meaning that both Table A and Table B have some shortened names.</p>
  
  <p>Here are some more examples:</p>
  
  <p><img src="https://i.stack.imgur.com/0c0Nn.png" alt="enter image description here"></p>
  
  <p>This is my current code.</p>
  
  <pre><code>Select *
  FROM TableA p
  JOIN TableB e ON e.CompanyNumber = 1 and e.LastName like '%' + rtrim(ltrim(p.lastname)) + '%' 
       and e.FirstName like '%' + ltrim(rtrim(p.firstname)) + '%' 
  </code></pre>
  
  <p>NOTE: This is the only way to match the tables together.</p>