Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id AA971632C19 for ; Mon, 2 Feb 2009 17:39:04 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 45253-01 for ; Mon, 2 Feb 2009 17:38:56 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 74ED7632C5C for ; Mon, 2 Feb 2009 17:38:56 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n12LctBm008610; Mon, 2 Feb 2009 16:38:55 -0500 (EST) To: "Haszlakiewicz, Eric" cc: pgsql-interfaces@postgresql.org Subject: Re: char columns, space padding, and the "like" operator In-reply-to: <9D29FD18CBD74A478CBA86E6EF6DBAD403394D9A@CHI4EVS04.corp.transunion.com> References: <9D29FD18CBD74A478CBA86E6EF6DBAD403394D9A@CHI4EVS04.corp.transunion.com> Comments: In-reply-to "Haszlakiewicz, Eric" message dated "Mon, 02 Feb 2009 15:00:33 -0600" Date: Mon, 02 Feb 2009 16:38:55 -0500 Message-ID: <8609.1233610735@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200902/3 X-Sequence-Number: 6854 "Haszlakiewicz, Eric" writes: > Once I realized that the value in the table actually got extended to > 'SOMEVALUE ', things started making sense, since the equivalent quick > select is actually: > select 'SOMEVALUE ' like 'SOME% %'; > Unfortunately, my app has a whole bunch of places where it uses > constructs like this against char columns. Other databases (such as > Informix), automatically strip spaces off char column so queries like > the above behave in a more intuitive fashion. Cast the char(n) column to text or varchar, and it should work more like you're expecting. regards, tom lane