Re: Case insensitive select

From: "isaac flemmin" <isaac(at)knox(dot)net>
To: <josh(at)agliodbs(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Case insensitive select
Date: 2002-06-13 01:27:02
Message-ID: 000001c21279$6c2fcd10$ad463e04@ixic
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thanks for the prompt reply, but while I was waiting for a reply I
discovered that using the RE operator '~*' will give me results, but if
in col1 there is are both 'value', and 'value1' and I look for value by
doing

SELECT * FROM test1 WHERE col1 ~* '^value';

I get both of them, value, and value1.

(I freely admit I do not know much about regular expressions so I will
continue to read about them and see if I can get something to work for
me, but while I am working on that any more advice would be helpful!)

Also I did try ILIKE before I wrote the email and it did not work for me
unless I would put a % at the end of the string, eg.

SELECT * FROM test1 WHERE col1 ILIKE 'value';

would not return any results, but

SELECT * FROM test1 WHERE col1 ILIKE 'value%';

would return both the rows with value and value1. Neither of these are
acceptable, because I only want to find exact matches that are case
insensitive. I have been reading the documentation on operators and
functions but as of yet, have not discovered anything that will work
correctly 100% of the time. So once again I would appreciate any ideas
on why this may not be working for me.

Thanks again for the reply.
Isaac
--

-----Original Message-----
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Josh Berkus
Sent: Wednesday, June 12, 2002 6:08 PM
To: isaac flemmin; pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Case insensitive select

Issac,

> I am doing something wrong or it would be working. I really have no
idea
> how to do a case insensitive query other than with the lower function.
> If there is anyone out there who has any ideas on how to help me or
can
> point me toward something that will help me it would be very
> appreciated.

There is also:

SELECT * FROM test1 WHERE col1 ~* '^value';
or:
SELECT * FROM test1 WHERE col1 ILIKE 'value';

See Operators and Functions in the online docs.

--
-Josh Berkus

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2002-06-13 01:34:05 Re: Case insensitive select
Previous Message Josh Berkus 2002-06-13 01:08:19 Re: Case insensitive select