Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B4773475498 for ; Thu, 8 Aug 2002 07:33:00 -0400 (EDT) Received: from superfly.archi-me-des.de (unknown [62.8.212.177]) by postgresql.org (Postfix) with ESMTP id A0D7F47546C for ; Thu, 8 Aug 2002 07:32:59 -0400 (EDT) Received: (from frank@localhost) by superfly.archi-me-des.de (8.9.3/8.9.3) id NAA16123 for pgsql-sql@postgresql.org; Thu, 8 Aug 2002 13:33:00 +0200 Date: Thu, 8 Aug 2002 13:33:00 +0200 From: Frank Joerdens To: pgsql-sql@postgresql.org Subject: to_char and '=' weirdness Message-ID: <20020808133300.A15630@superfly.archi-me-des.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.1.2i X-Subliminal-Message: Use Linux! Use Linux! X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/144 X-Sequence-Number: 8990 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