pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: Lynna Landstreet <lynna@gallery44.org>
To: pgsql-php@postgresql.org
Subject: Re: Case sensitivity when searching for and displaying data
Date: Thu, 4 Sep 2003 14:17:12 +0800
Message-ID: <036b01c372ac$2dd63420$2800a8c0@mars> (raw)
References: <BB7BE411.AB4%lynna@gallery44.org>

> I've gotten a simple PHP search page working on the artists database that
> I've been developing these past few months, but I'm running into a few
> problems with PostgreSQL's case sensitivity.

No, you've been used to MySQL case insensitity methinks...

> Ideally I'd like the search text to case insensitive, so that if the user
> enters "jane smith", "Jane Smith" or "JANE SMITH", they'll still find the
> record for Jane Smith. But I'm not sure how to do that.

Use ILIKE:

SELECT * FROM table WHERE name ILIKE 'jane smith';

Or LOWER:

SELECT * FROM table WHERE LOWER(name) = LOWER('JANE SMITH');

(it'll help you to make a functional index in this case)

> Secondly, the case sensitivity thing is also messing up the order of the
> displayed results. Right now I have them set to order by lastname, and
that
> makes any names that begin with a lower case character come at the end of
> the list because of the order of the ASCII values of the letters, rather
> than where they would normally be in alphabetical order. Does anyone know
if
> there's a way around this?

Use LOWER:

SELECT * FROM table WHERE LOWER(name) = LOWER('JANE SMITH') ORDER BY
LOWER(name);

Chris




view thread (6+ messages)  latest in thread

Message-ID: <036b01c372ac$2dd63420$2800a8c0@mars>
Permalink:  ../036b01c372ac$2dd63420$2800a8c0@mars/
Also on:    postgresql.org/message-id/036b01c372ac$2dd63420$2800a8c0@mars

 · 

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: chriskl@familyhealth.com.au, lynna@gallery44.org
  Subject: Re: Case sensitivity when searching for and displaying data
  In-Reply-To: <036b01c372ac$2dd63420$2800a8c0@mars>
  References: <BB7BE411.AB4%lynna@gallery44.org> <036b01c372ac$2dd63420$2800a8c0@mars>

* 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