title: Compare comma delimited strings in SQL
body: <p>I have search requests that come in a CDL <code>("1,2,3,4")</code>,<code>("1,5")</code>. I need to compare that to another CDL and return back all records that have a match. The kicker is the position of each number isn't always the same.</p>
  
  <p>I've got something almost working except for instances where I'm trying to match <code>("2,5")</code> to <code>("2,4,5")</code>. Obviously the strings aren't equal but I need to return that match, because it has all the values in the first CDL.</p>
  
  <p><a href="http://www.sqlfiddle.com/#!3/2cf8b/5/0" rel="nofollow noreferrer">My SQL Fiddle should make it fairly clear...</a> </p>
  
  <p>Any help would be much appreciated.</p>
  
  <p>Oh and I saw this <a href="https://stackoverflow.com/questions/4215902/search-a-varchar-field-that-contains-all-words-from-another-string">one</a> is similar, but that seems a little drastic and over my head but I'll see if I can try to understand it.</p>
  
  <p><strong>Edit</strong><br>
  So I just did a replace to change <code>("2,5")</code> to <code>("%2%5%")</code> and changed the were to use <code>LIKE</code>. From what I can initially tell it seems to be working.. <a href="http://www.sqlfiddle.com/#!3/909f2/1/0" rel="nofollow noreferrer">SQL Fiddle</a> Any reason I shouldn't do this or maybe I'm crazy and it doesn't work at all?</p>