pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew McMillan <andrew@catalyst.net.nz>
To: Hervé Piedvache <herve@elma.fr>
Cc: Zhidian Du <duzhidian@hotmail.com>
Cc: pgsql-php@postgresql.org
Subject: Re: search/select case-insensitivly.
Date: 22 Oct 2002 23:22:47 +1300
Message-ID: <1035282167.6372.153.camel@kant.mcmillan.net.nz> (raw)
In-Reply-To: <20021022091245.50B5641812@mailer.elma.fr>
References: <F102Xb29dhyCHrmTiKT00001e1c@hotmail.com>
	<1035274378.6376.105.camel@kant.mcmillan.net.nz>
	<20021022091245.50B5641812@mailer.elma.fr>

On Tue, 2002-10-22 at 22:10, Hervé Piedvache wrote:
> The best way is to always save data in your database in the same format ... 
> upper or lower ... then create an index on your field classicaly ...
> 
> CREATE INDEX ix_name ON mytable(name);
> SELECT name FROM mytable WHERE name = '" . strtolower($Name) ."';
> 
> You will ever use the index ... and it's simple to implement ...
> You can also easily do an update of your database like :
> update mytable set name=lower(name);
> to get all the old data in the good format ...
> Do not forget to vacuum the table after that !

Yes, of course you can do that - I was assuming there was a reason why
the poster wanted case preserved.

I generally preserve case for email addresses, for example.  Sometimes
the LHS of an e-mail address is case sensitive, even though the RHS
(domain name) may not be.  Searching on such a field, however, I would
probably want to search case insensitively.

There are other reasons for preserving case, of course - especially the
case that people write their names.  I usually write my own name
McMillan, and it _infuriates_ me when I see software that has translated
that to Mcmillan.  Lest you think that is easily computed, I know people
with names which are correctly capitalised as Macindoe and Macinnes -
the capitalisation is idiosyncratic.  If you remove the capitalisation
when you write those values to the file you are removing potentially
valuable information.


Finally, you should also consider:

update mytable set name=lower(name) WHERE name != lower(name);

will require a lot less vacuuming :-)

Cheers,
					Andrew.
-- 
---------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/         PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201     MOB: +64(21)635-694    OFFICE: +64(4)499-2267
           Survey for free with http://survey.net.nz/ 
---------------------------------------------------------------------




view thread (7+ messages)  latest in thread

Message-ID: <1035282167.6372.153.camel@kant.mcmillan.net.nz>
Permalink:  ../1035282167.6372.153.camel@kant.mcmillan.net.nz/
Also on:    postgresql.org/message-id/1035282167.6372.153.camel@kant.mcmillan.net.nz

 · 

reply

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: andrew@catalyst.net.nz, herve@elma.fr, duzhidian@hotmail.com
  Subject: Re: search/select case-insensitivly.
  In-Reply-To: <1035282167.6372.153.camel@kant.mcmillan.net.nz>
  References: <F102Xb29dhyCHrmTiKT00001e1c@hotmail.com> <1035274378.6376.105.camel@kant.mcmillan.net.nz> <20021022091245.50B5641812@mailer.elma.fr> <1035282167.6372.153.camel@kant.mcmillan.net.nz>

* 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