From: Bruno Wolff III <bruno@wolff.to>
To: Zhidian Du <duzhidian@hotmail.com>
Cc: pgsql-php@postgresql.org
Subject: Re: search/select case-insensitivly.
Date: Tue, 22 Oct 2002 06:46:28 -0500
Message-ID: <20021022114628.GA28016@wolff.to> (raw)
In-Reply-To: <F102Xb29dhyCHrmTiKT00001e1c@hotmail.com>
References: <F102Xb29dhyCHrmTiKT00001e1c@hotmail.com>
On Mon, Oct 21, 2002 at 22:01:19 -0600,
Zhidian Du <duzhidian@hotmail.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');
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: bruno@wolff.to, duzhidian@hotmail.com
Subject: Re: search/select case-insensitivly.
In-Reply-To: <20021022114628.GA28016@wolff.to>
References: <F102Xb29dhyCHrmTiKT00001e1c@hotmail.com> <20021022114628.GA28016@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox