Please buff my shoes: RLIKE & LIKE
Posted: Wed Feb 12, 2003 9:33 pm
I'm writing my first search script and I want to be able to find a word wherever it appears in a field.
If I search for LIKE 'buff' it will only find columns = "buff" but NOT those with "please buff my shoes".
If I search for LIKE '%buff%' I get "please buff my shoes" OK, but also anything with "rebuffed" or "buffy" - which I don't want.
So, I tried RLIKE which, according to the manual, looks for a string anywhere within a field - different to the behaviour of LIKE with no wildcards which (I think) is looking for an exact match.
However, RLIKE '^buff$' seems to be behaving same as LIKE 'buff' ie it will find fields with "buff" but NOT "please buff my shoes".
Is there a way to find single words with a mysql query? I could probably process the initial mysql results down to what I want in php but that's going to create a lot of overhead with a big result set.
If I search for LIKE 'buff' it will only find columns = "buff" but NOT those with "please buff my shoes".
If I search for LIKE '%buff%' I get "please buff my shoes" OK, but also anything with "rebuffed" or "buffy" - which I don't want.
So, I tried RLIKE which, according to the manual, looks for a string anywhere within a field - different to the behaviour of LIKE with no wildcards which (I think) is looking for an exact match.
However, RLIKE '^buff$' seems to be behaving same as LIKE 'buff' ie it will find fields with "buff" but NOT "please buff my shoes".
Is there a way to find single words with a mysql query? I could probably process the initial mysql results down to what I want in php but that's going to create a lot of overhead with a big result set.