Problem with lower(

Problem with lower(

am 06.11.2006 23:45:51 von Mad Hatter

Hi

I'm trying to find data in a database. The data is in mixed case. I'm
trying to find all occurances of a particular string but the string isn't
in the same case all the time. For example I could be looking for the word
'fred' but in the database it could be 'Fred', 'FRED', 'fred' etc. I'm
using the following which seems to work on some servers but not others.

$q="SELECT id FROM $dbfilenames WHERE type='b' AND LOWER(name) LIKE
'%$se%'";

Any thoughts as to why this works on some and not on others and a possible
work around for it?

Re: Problem with lower(

am 07.11.2006 12:04:27 von zac.carey

Mad Hatter wrote:
> Hi
>
> I'm trying to find data in a database. The data is in mixed case. I'm
> trying to find all occurances of a particular string but the string isn't
> in the same case all the time. For example I could be looking for the word
> 'fred' but in the database it could be 'Fred', 'FRED', 'fred' etc. I'm
> using the following which seems to work on some servers but not others.
>
> $q="SELECT id FROM $dbfilenames WHERE type='b' AND LOWER(name) LIKE
> '%$se%'";
>
> Any thoughts as to why this works on some and not on others and a possible
> work around for it?

Odd, I would have guessed that LOWER was redundant in this context,
because only BOOLEAN MODE searches are case sensitive in MySQL. Can you
echo the query so we can see exactly what's being submitted?

Re: Problem with lower(

am 11.11.2006 01:00:44 von Mad Hatter

>>
>> $q="SELECT id FROM $dbfilenames WHERE type='b' AND LOWER(name) LIKE
>> '%$se%'";
>>
>
> Odd, I would have guessed that LOWER was redundant in this context,
> because only BOOLEAN MODE searches are case sensitive in MySQL. Can you
> echo the query so we can see exactly what's being submitted?

I did in the original post. It's shown above. $se is pulled in from a form.
I've tried it on a few servers. It works properly on all except one and I
don't have access to php.ini to see what's different. Basically what I'm
trying to do, when someone enters Fred in the form it'll find all entries
with fred in it in any case. So, Fred, fred, frederik, freda, FREDA etc
would all be found. It works perfectly on all except the one server :-(