Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 24F38475F18 for ; Tue, 22 Oct 2002 07:37:28 -0400 (EDT) Received: from wolff.to (unknown [66.93.197.35]) by postgresql.org (Postfix) with SMTP id 6AAB2475C26 for ; Tue, 22 Oct 2002 07:37:27 -0400 (EDT) Received: (qmail 28240 invoked by uid 500); 22 Oct 2002 11:46:28 -0000 Date: Tue, 22 Oct 2002 06:46:28 -0500 From: Bruno Wolff III To: Zhidian Du Cc: pgsql-php@postgresql.org Subject: Re: search/select case-insensitivly. Message-ID: <20021022114628.GA28016@wolff.to> Mail-Followup-To: Zhidian Du , pgsql-php@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.25i X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/49 X-Sequence-Number: 1564 On Mon, Oct 21, 2002 at 22:01:19 -0600, Zhidian Du 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');