I have three different MYSQL queries I am attempting to use to search a single column (classlist); the goal is that the column should contain _10_
but should not contain _3_
or _15_
(an example value might be something like _4_8_10_15_
which would fail given the _15_
).
I have tried three different approaches and all three give no errors and yet different results:
1) FULLTEXT searching (with the FULLTEXT index enabled on classlist) returned no errors and yet also returned no results.
SELECT classlist, classcount FROM subgroupstest WHERE MATCH (classlist) AGAINST ('+10 -3 -15' IN BOOLEAN MODE)
2) Simple LIKE clauses returned 516 rows.
SELECT classlist, classcount FROM subgroupstest WHERE classlist LIKE "%_10_%" AND classlist NOT LIKE "%_3_%" AND classlist NOT LIKE "%_15_%"
3) A LIKE/REGEXP hybrid returned 1,912 results. One example it returned that the second approach did not was _4_10_18_23_
- this is an accurate result, and there are no duplicates in this result so I have to assume the second approach (no less the first!) is missing something somehow.
SELECT classlist, classcount FROM subgroupstest WHERE classlist LIKE '%_10_%' AND classlist NOT REGEXP '_3_|_15_'
At this point I'm left shaking my head and unsure what is going on. There are always deeper issues I could try to look for, but can someone verify if I'm even doing the REGEXP and/or FULLTEXT approaches correctly? It looks like what I've seen on Google after the last few hours of reading and mimicking, but it's my first time using either of those.