pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: "D'Arcy" "J.M." Cain <darcy@druid.net>
To: pierre@desertmoon.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Quickie
Date: Mon, 8 Feb 1999 17:49:35 -0500 (EST)
Message-ID: <m109zUm-0000bNC@druid.net> (raw)
In-Reply-To: <19990208215723.11594.qmail@desertmoon.com>

Thus spake pierre@desertmoon.com
> Given:
> User_Email|User_ID
> -------------------
> fubar     | 1
> barfu     | 2
> snafu     | 3
> Fubar     | 4
> 
> What query could I use to return ONLY 'fubar' and 'Fubar'? Would I do a self

Well, the obvious is;

  SELECT * FROM x WHERE User_Email = 'fubar' OR User_Email = 'Fubar';

But I assume you are looking for something more useful.  Are you trying
to catch all entries not in all lower case?  Try this:

  SELECT * FROM x WHERE User_Email != lower(User_Email);

Or you can convert to lower with this:

  UPDATE x SET User_Email = LOWER(User_Email);

If you have a unique index on User_Email then the ones that already
exist will fail and then you can use the first one to find the ones
that didn't get converted.  Those will be the dups.

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 424 2871     (DoD#0082)    (eNTP)   |  what's for dinner.



view thread (3+ messages)

Message-ID: <m109zUm-0000bNC@druid.net>
Permalink:  ../m109zUm-0000bNC@druid.net/
Also on:    postgresql.org/message-id/m109zUm-0000bNC@druid.net

 · 

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-sql@postgresql.org
  Cc: darcy@druid.net, pierre@desertmoon.com
  Subject: Re: [SQL] Quickie
  In-Reply-To: <m109zUm-0000bNC@druid.net>
  References: <19990208215723.11594.qmail@desertmoon.com> <m109zUm-0000bNC@druid.net>

* 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