I want to search an string on occurences of a substring. But I want to limit them to specific amounts to detect.
My angles VARCHAR looks like this:
0,90,0,90,180,180,270,0,270,0,90
My first attempt was with a LIKE statement. But I cannot count the occurences then:
SELECT *   FROM anglesTable WHERE corners LIKE "%180%' AND corners LIKE "%270%'  LIMIT 1000 
my second try was this:
 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
But that is too slow.
I want to know if there's a more faster way to query this through a database of 3 million entries.
If there's a better way to search this kind of data, advise would be welcome.