title: matching comma separated values in MySQL on join
body: <p>I have a few tables i need to join, i cannot change the database as it's being used in multiple different applications.</p>
  
  <p>The first table looks like the following</p>
  
  <pre><code>id, list_of_foreign_id
  
  
  1, "1, 3, 4, 8, 12, 13, 14, 15, 16, 23"
  
  2, "1, 3, 4, 8, 23"
  
  3, "1, 3, 8, 12, 13, 14, 15, 23"
  
  4, "7"
  
  ....
  </code></pre>
  
  <p>And the forrening table is simply joined on ID and could look like the following</p>
  
  <pre><code>ID, name
  
  1, "john Oliver"
  
  2, "John Doe"
  
  3, "Arthur Dent"
  
  ....
  </code></pre>
  
  <p>And i need to match the list of ids in table to to the id on table two.</p>
  
  <p>The query is going to look like the following but i'm unsure about the join condition</p>
  
  <pre><code>Select ...
  from
  A
  join
  B on a.list_of_foreign_id contains B.id
  </code></pre>
  
  <p>I'm thinking it can be done using regex.</p>
  
  <p>I've tried with locate, but it also matches sub-strings like 1, 3 will match to 13. etc.</p>
  
  <p>I've also looked around and found this post, 
  <a href="https://stackoverflow.com/questions/16620980/comma-separated-numbers-regex">Comma Separated Numbers Regex</a>
  But I'm unsure how to look with regex for specific cases.</p>