Given the text:
"Hello, I'm from Hell",
"Hello, I'm from Ell"
and the following SQL clause:
SELECT * FROM table WHERE text LIKE '%ell%'
I get both the texts above, but I don't want to get both texts, because I was looking for the text "Ell" and not "Hell"
If anyone knows what I mean, can you help me out?
Thanks in advance!
EDIT:
BETTER EXAMPLE
Like when you want to look for the word 'big' but it can't be part of any other word like 'bigger' or 'biggest'
You could use the MySQL Regex word boundary matching:
SELECT * FROM table WHERE text REGEXP '[[:<:]]ell[[:>:]]'
This matches a string which cosntains the word ell with a word boundary on either side.
Can you search for a space as well?
SELECT *
FROM table
WHERE text LIKE '% ell%'
OR text LIKE 'ell%' // needed if string starts with ell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With