title: "Like" operator in inner join in SQL
body: <p>Using Sequel Pro, I have these two tables:</p>
  
  <pre><code>Table1
  
  Name         Year    x      y
  John Smith   2010    10     12
  Adam Jones   2010    8      13
  John Smith   2011    7      15
  Adam Jones   2011    9      14
  etc.
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Table2
  
  Name                    Year  z    
  Smith John Smith John   2010  27
  Jones Adam Jones Adam   2010  25
  Smith John Smith John   2011  29
  Jones Adam Jones Adam   2011  21
  etc.
  </code></pre>
  
  <p>Basically, the names in Table2 are the same only with the last name and first name switched, then repeated once. So the Names in Table1 are found in the names of Table2 ("John Smith" is found in "Smith <strong>John Smith</strong> John"). I want to perform an inner join and connect the z value of Table2 to the other values of Table1 and get something like this:</p>
  
  <pre><code>Name       x     y     z
  John Smith 10    12    27
  Adam Jones 8     13    25
  </code></pre>
  
  <p>So to do that, I ran this query:</p>
  
  <pre><code>Select Table1.*, Table2.z
  From Table1
  Inner join Table2
  On Table1.Name like "%Table2.Name%" and Table1.Year=Table2.Year
  </code></pre>
  
  <p>But I got this as the output:</p>
  
  <pre><code>Name  Year  x  y  z
  </code></pre>
  
  <p>And that's it. I got the headings, but no rows. I don't know what I'm doing wrong... I suspect it probably has to do with the way I'm using the like operator but I don't know. Any help would be much appreciated.</p>