pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <jconway2@home.com>
To: Mark <mark@zserve.com>
To: pgsql-sql@postgresql.org
Subject: Re: Case Insensitive Queries
Date: Tue, 29 May 2001 09:54:39 -0700
Message-ID: <005701c0e860$0d3d9ce0$dad410ac@jecw2k1> (raw)
References: <200105291603.f4TG3BW08512@mail.ldssingles.com>

> Is it possible to execute a query using a where clause that allows case
> insensitive comparison between a field and text.
>
> For example:
>
> select * from account where username = 'test'
>
> where username could be 'Test', which would be a match.  As is, this
> compare is case sensitive.
>

You can use ~* (see 4.5.2. POSIX Regular Expressions
http://www.postgresql.org/idocs/index.php?functions-matching.html ) or force
everything to either upper or lower using the same named functions (see 4.4.
String Functions and Operators
http://www.postgresql.org/idocs/index.php?functions-string.html ). You can
build an index on upper(username) or lower(username), so that may be a good
choice if you don't really need a regular expression.

Hope this helps,

-- Joe





view thread (19+ messages)  latest in thread

Message-ID: <005701c0e860$0d3d9ce0$dad410ac@jecw2k1>
Permalink:  ../005701c0e860$0d3d9ce0$dad410ac@jecw2k1/
Also on:    postgresql.org/message-id/005701c0e860$0d3d9ce0$dad410ac@jecw2k1

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jconway2@home.com, mark@zserve.com
  Subject: Re: Case Insensitive Queries
  In-Reply-To: <005701c0e860$0d3d9ce0$dad410ac@jecw2k1>

* 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