How can I do a ‘like’ search to begin from the start of each word.
I do not want to limit the number of characters typed.
a.title LIKE ‘%“.$srch.”%’
So ‘claw’ would be found here:
CLAW
Large CLAWs
But not found in
Large Gripclaws
How can I do a ‘like’ search to begin from the start of each word.
I do not want to limit the number of characters typed.
a.title LIKE ‘%“.$srch.”%’
So ‘claw’ would be found here:
CLAW
Large CLAWs
But not found in
Large Gripclaws
You would use regexp, with a beginning word boundary pattern -
a.title REGEXP '[[:<:]]$srch'
If you are still putting external, unknown, dynamic values directly into sql query statements, e.g. the $srch variable, you need to switch to use prepared queries, and use the much simpler and better designed PDO extension.
You can easily use like without the % at the beginning
That would match the start of the field, not the start of each word.
You are right. I have overridden the word each..