[Phpwm] MySQL case insensitive string comparison

Alex Mace alex at hollytree.co.uk
Thu Jun 24 13:01:55 UTC 2010


I think it will depend where you're using that collation. AFAIK you can set it at the table level, server level and client level. I'm not 100% sure on where the correct place to set it to get the case insensitive matching you're after, but try each and see what happens.

On 24 Jun 2010, at 13:56, Mike Tipping wrote:

> There isn't a iLike in Mysql. :o(
> 
> I’ve stated to use
> 
> select * from table where lower(name) = lower(‘$value’) 
> 
> Which works but that doesn’t seem a very efficient way of tying to get it to behave as it should be behaving in the first place.
> 
> 
> 
> 
> On 24/06/2010 13:49, "Dan Dart" <dandart at googlemail.com> wrote:
> 
>> Have you tried using the lower/upper/camel case instructions in PHP to make MySQL see what you want?
>> 
>> Jolly confusing how it all seems to contradict itself.
>> 
>>> On 24 Jun 2010 13:39, "Mike Tipping" <mike at etuna.co.uk> wrote:
>>> 
>>> Whenever I run a select in Mysql based on a string comparison, the
>>> comparison is always case sensitive so where 'name' in the DB is 'mike',
>>> select * from table where name = 'MIKE'; won't return results.
>>> 
>>> Looking at the MySQL documentation it says that case sensitivity on
>>> comparisons depends on the collation and if I use 'latin1_swedish_ci' (which
>>> I do) the comparison will be case insensitive (which it isn't).
>>> 
>>> It also says that STRCMP() is by default case insensitive, but when I try
>>> that it still doesn't return anything.
>>> 
>>> Any ideas what I might be doing wrong or what I can use to do a case
>>> insensitive string comparison in MySQL.
>>> 
>>> Cheers
>>> 
>>> Mike
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> Phpwm mailing list
>>> Website : http://www.phpwm.org
>>> Twitter : http://www.twitter.com/phpwm
>>> Facebook: http://www.facebook.com/group.php?gid=2361609907
>>> 
>>> Post to list: Phpwm at mailman.lug.org.uk
>>> Archive etc : https://mailman.lug.org.uk/mailman/listinfo/phpwm
>> 
>> _______________________________________________
>> Phpwm mailing list
>> Website : http://www.phpwm.org
>> Twitter : http://www.twitter.com/phpwm
>> Facebook: http://www.facebook.com/group.php?gid=2361609907
>> 
>> Post to list: Phpwm at mailman.lug.org.uk
>> Archive etc : https://mailman.lug.org.uk/mailman/listinfo/phpwm
> _______________________________________________
> Phpwm mailing list
> Website : http://www.phpwm.org
> Twitter : http://www.twitter.com/phpwm
> Facebook: http://www.facebook.com/group.php?gid=2361609907
> 
> Post to list: Phpwm at mailman.lug.org.uk
> Archive etc : https://mailman.lug.org.uk/mailman/listinfo/phpwm

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.lug.org.uk/pipermail/phpwm/attachments/20100624/24316157/attachment.htm 


More information about the Phpwm mailing list