From: Frank Joerdens <frank@joerdens.de>
To: pgsql-sql@postgresql.org
Subject: to_char and '=' weirdness
Date: Thu, 8 Aug 2002 13:33:00 +0200
Message-ID: <20020808133300.A15630@superfly.archi-me-des.de> (raw)
German area codes from the former east all have a leading zero. As I
store area codes as integers, I use to_char to find those with a leading
zero, as in
select * from adressen where to_char(plz, '00000') like '%04109%';
(this would be Leipzig)
What I don't understand is why something like
select * from adressen where to_char(plz, '00000') = '04109';
will yield 0 rows. If I do
archi=# select to_char(plz, '00000') from adressen where
archi-# to_char(plz, '00000') like '%04109%';
I get:
to_char
---------
04109
04109
04109
04109
04109
04109
04109
04109
04109
04109
04109
04109
04109
04109
04109
(15 rows)
(i.e. my database contains 15 addresses from Leipzig)
which would appear to indicate that to_char actually yields the string
'04109'. Why doesn't the '=' operator work then?
Regards, Frank
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: frank@joerdens.de
Subject: Re: to_char and '=' weirdness
In-Reply-To: <20020808133300.A15630@superfly.archi-me-des.de>
* 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