Skip site navigation (1) Skip section navigation (2)

Re: Data conversion in query

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Tad Marko <tad(at)tadland(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Data conversion in query
Date: 2003-03-27 20:05:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Thu, Mar 27, 2003 at 13:43:10 -0600,
  Tad Marko <tad(at)tadland(dot)net> wrote:
> Hello,
> I'm having a small difficulty that I am hopeful there is a simple solution 
> for. Basically, I am doing a join on a column that is numeric in one 
> database but a string in the other. Something like:
> ...WHERE a.numeric_zipcode=b.string_zipcode::integer...
> The problem is that occasionally the string zip field has some 
> non-numeric characters. Unfortunatley, I cannot control the sanity of the 
> string zip field. The question is if there is any way that in the same 
> query I can filter out the rows that have non-number characters in the zip 
> field?

Why don't you compare them as strings? You can use to_char to force the
numeric zip code to 5 digits.

In response to

pgsql-general by date

Next:From: Robert TreatDate: 2003-03-27 20:17:35
Subject: Re: Long term read-only records?
Previous:From: philo viveroDate: 2003-03-27 20:05:08
Subject: Re: PostgreSQL + IDS load/latency help

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group