From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Remigiusz Sokolowski <rems@gdansk.sprint.pl>
To: Frank Morton <fmorton@base2inc.com>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Newbie questions
Date: Tue, 15 Dec 1998 15:13:03 +0200
Message-ID: <l0311070eb29c0a1081e5@[147.233.159.109]> (raw)
In-Reply-To: <Pine.GS4.4.02A.9812140916340.14291-100000@netra.gdansk.sprint.pl>
References: <010001be270b$0070f980$8355e5ce@tesla.base2inc.com>
At 10:26 +0200 on 14/12/98, Remigiusz Sokolowski wrote:
> > select * from animals where id='dogs' ignore case;
>
> look at operators in docs
> ~~ - LIKE operator
> ~* - match(regex), case insensitive operator
> I have no idea which is better
> Rem
> p.s. I could make some mistakes in this examples - check in amnual or docs
The like and regexp do a match rather than an equality test.
For an exact equality ignoring case, simply use
SELECT *
FROM animals
WHERE lower( id ) = 'dogs';
Note that this means an index on the id column will NOT be used, because
each value has to be converted to lower before testing. When I needed this
to be an indexed search, I added a column, called, say "lower_id", which
contains the lowercase version of the value in the "id" column. Then I
indexed that column and then you can ask WHERE lower_id = 'dogs' and get a
fast answer.
There is also the possibility of creating a functional index, but I haven't
managed to cause this sort of index to "kick in" on my version of postgres
(6.2.1).
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
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-sql@postgresql.org
Cc: herouth@oumail.openu.ac.il, rems@gdansk.sprint.pl, fmorton@base2inc.com
Subject: Re: [SQL] Newbie questions
In-Reply-To: <l0311070eb29c0a1081e5@[147.233.159.109]>
References: <010001be270b$0070f980$8355e5ce@tesla.base2inc.com> <l0311070eb29c0a1081e5@[147.233.159.109]>
* 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