title: Matching similar city names in SQL
body: <p>I have a table "City" which contains city names, and I have a another table which I just created and contains cities from different sources. When I run a query to match the cities between the two tables I find about 5000 mismatches. </p>
  
  <p>So please give some queries which I can use to match cities (because sometimes users enter city names with one or two character different)... I have created a query which is working fine but I need such a query to match more.</p>
  
  <p>Please suggest me what to do in such a situation.</p>
  
  <pre><code>SELECT distinct hsm.countryname,co.countryname,hsm.city,co.city
  FROM   HotelSourceMap AS hsm
  INNER  JOIN 
      (  SELECT c.*,cu.countryName
         FROM   city c
         INNER  JOIN  country cu ON c.countryid= cu.countryId
      ) co
  ON (charindex(co.city,hsm.city) &gt; 0 AND hsm.countryid = co.countryid) AND
      hsm.cityid is null
  </code></pre>