title: count occurences of substring with limit on amounts of substring
body: <p>I want to search an string on occurences of a substring. But I want to limit them to specific amounts to detect. </p>
  
  <p>My angles VARCHAR looks  like this: </p>
  
  <pre><code>0,90,0,90,180,180,270,0,270,0,90
  </code></pre>
  
  <p>My first attempt was with a LIKE statement. But I cannot count the occurences then: </p>
  
  <pre><code>SELECT *   FROM anglesTable WHERE corners LIKE "%180%' AND corners LIKE "%270%'  LIMIT 1000 
  </code></pre>
  
  <p>my second try was this:</p>
  
  <pre><code> SELECT  *, foo.counts270,foo.counts180,foo.counts60 FROM 
     (
       SELECT anglesNew.*, 
              LENGTH( corners) - LENGTH(REPLACE(corners, '270', '')) AS counts270,
              LENGTH( corners) - LENGTH(REPLACE(corners, '180', '')) AS counts180, 
              LENGTH( corners) - LENGTH(REPLACE(corners, '60', '')) AS counts60 
       FROM anglesNew 
     ) as foo
  </code></pre>
  
  <p>But that is too slow.</p>
  
  <p>I want to know if there's a more faster way to query this through a database of 3 million entries. </p>
  
  <p>If there's a better way to search this kind of data, advise would be welcome.</p>