pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andy Lewis <alewis@themecca.net>
To: Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
Cc: pgsql-sql@hub.org
Subject: Re: [SQL] Case insensitive searchs
Date: Sun, 18 Apr 1999 13:58:30 -0500 (CDT)
Message-ID: <Pine.LNX.4.05.9904181357590.21774-100000@tmg.themecca.net> (raw)
In-Reply-To: <m10YwYZ-000LJrC@wallace.ece.rice.edu>

Thanks much! 

I've solved my problem.

Much appreciated.

Andy

On Sun, 18 Apr 1999, Ross J. Reedstrom wrote:

> There's more than one way to do it, and some interesting SQL text functions
> to use with it, as well, as demonstrated by the example below:
> 
> test=> create table addr_table (city text, state text);
> CREATE
> test=> insert into addr_table values ('SAN ANTONIO', 'TX');
> INSERT 25354 1
> test=> insert into addr_table values ('San Antonio', 'TX');
> INSERT 25355 1
> test=> insert into addr_table values ('San antonio', 'tx');
> INSERT 25356 1
> test=> insert into addr_table values ('san antonio', 'Tx');
> INSERT 25357 1
> test=> select * from addr_table;
> city       |state
> -----------+-----
> SAN ANTONIO|TX   
> San Antonio|TX   
> San antonio|tx   
> san antonio|Tx   
> (4 rows)
> 
> test=> select * from addr_table group by city; 
> city       |state
> -----------+-----
> SAN ANTONIO|TX   
> San Antonio|TX   
> San antonio|tx   
> san antonio|Tx   
> (4 rows)
> 
> test=> select * from addr_table group by lower(city);
> city       |state
> -----------+-----
> SAN ANTONIO|TX   
> (1 row)
> 
> 
> test=> select initcap(city),upper(state) from addr_table group by lower(city);
> initcap    |upper
> -----------+-----
> San Antonio|TX   
> (1 row)
> 
> test=> select distinct initcap(city),upper(state) from addr_table;              
> initcap    |upper
> -----------+-----
> San Antonio|TX   
> (1 row)
> 
> 
> > I have a table that has city names in it. Some of the cities have a number
> > of different cases. For instance I may have:
> > 
> > 	San Antonio
> > 	san antonio
> > 	San antonio
> > 	SAN ANTONIO
> > 
> > My question is how can I do a distinct search for all cities and only get
> > one of each city?
> 
> HTH,
> Ross
> 
> -- 
> Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
> NSBRI Research Scientist/Programmer
> Computer and Information Technology Institute
> Rice University, 6100 S. Main St.,  Houston, TX 77005
> 




view thread (7+ messages)  latest in thread

Message-ID: <Pine.LNX.4.05.9904181357590.21774-100000@tmg.themecca.net>
Permalink:  ../Pine.LNX.4.05.9904181357590.21774-100000@tmg.themecca.net/
Also on:    postgresql.org/message-id/Pine.LNX.4.05.9904181357590.21774-100000@tmg.themecca.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: alewis@themecca.net, reedstrm@wallace.ece.rice.edu, pgsql-sql@hub.org
  Subject: Re: [SQL] Case insensitive searchs
  In-Reply-To: <Pine.LNX.4.05.9904181357590.21774-100000@tmg.themecca.net>
  References: <m10YwYZ-000LJrC@wallace.ece.rice.edu> <Pine.LNX.4.05.9904181357590.21774-100000@tmg.themecca.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