Multiple LIKE, OR MySql Queries Match
- by Codex73
Search for: 'chemist'
Problem: query which will match a string like 'onechemist' but not 'chemist'.
SELECT id,name FROM `records`
WHERE name LIKE '%". mysql_real_escape_string($q) ."%'
This alternate try won't work:
SELECT id,name FROM `records`
WHERE name LIKE '%". mysql_real_escape_string($q) ."%'
OR name LIKE '". mysql_real_escape_string($q) ."%'
OR name LIKE '%". mysql_real_escape_string($q) ."'
How could I compile the above into one single query that will match any field which has the string or optimize the query into a better expression?