Re: search/select case-insensitivly.

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Zhidian Du <duzhidian(at)hotmail(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: search/select case-insensitivly.
Date: 2002-10-22 11:46:28
Message-ID: 20021022114628.GA28016@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

On Mon, Oct 21, 2002 at 22:01:19 -0600,
Zhidian Du <duzhidian(at)hotmail(dot)com> 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');

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Maxim Maletsky 2002-10-22 13:02:15 Re: search/select case-insensitivly.
Previous Message Andrew McMillan 2002-10-22 10:22:47 Re: search/select case-insensitivly.