Re: search/select case-insensitivly.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, Oct 21, 2002 at 22:01:19 -0600,
  Zhidian Du <duzhidian@xxxxxxxxxxx> wrote:
> I want a PHP program to search case-insensitivly.
> 
> for example:
> select Name from mytable where Name = '$Name';
> 
> 
> Here $Name is what users' input maybe JOHN, john.  How to let it match John 
> in table and find that record?

As mentioned in other replies you can use the lower or upper functions
to get consistant case.

If you want case preerved in the table, you can make the searches faster
(at the expense of slowing down updates) by creating an index using a function.

Something like:
create index on table mytable(lower(Name));

Will speed up searches like:
select Name from mytable where lower(Name) = lower('$Name');


[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux