title: Mysql compare comma-separated field with single string
body: <p>So a field called schools in the database might have a value of:</p>
  
  <pre><code>'13,121,112,1212'
  </code></pre>
  
  <p>I'm using that to show the potential for a mistake.</p>
  
  <p>Suppose I'm looking for a value of <code>12</code> in that field.  The commas denote a "whole number" and I don't want to match 112 or 1212</p>
  
  <p>Is there a more elegant match than this?</p>
  
  <pre><code>@compare = 12;
  WHERE CONCAT(schools,',') LIKE CONCAT('%',compare,',%)
  </code></pre>
  
  <p>I was recently impressed by the GROUP_CONCAT function but this is kind of in reverse of that.  Thanks!</p>