Question

Is there a way to search by beginning of any substring in the record?

Concrete example would be:

Nike shoes, Shoes Nike, Sunick shoes

Suppose search string is 'ni'.

If I would use wild character on the end of the search string only I would get only first record. If I use wild char on both end I would get all three records.

Is there a way to get only first two?

Maybe to do search by to strings with wild char on the end, where second parameter would be identical to first but with prepended space.

Something like "WHERE field LIKE 'ni%' OR '% ni%'"

Was it helpful?

Solution

You can use a regular expression to match only strings that begin at a word boundary:

WHERE field REGEXP '[[:<:]]ni'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top