Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 76F16475FC4 for ; Tue, 14 Jan 2003 11:40:01 -0500 (EST) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by postgresql.org (Postfix) with ESMTP id 2F29C4764BF for ; Tue, 14 Jan 2003 11:34:42 -0500 (EST) Received: from andrew by mail.libertyrms.com with local (Exim 3.22 #3 (Debian)) id 18YU1X-0003ug-00 for ; Tue, 14 Jan 2003 11:34:47 -0500 Date: Tue, 14 Jan 2003 11:34:47 -0500 From: Andrew Sullivan To: pgsql-jdbc@postgresql.org Subject: Re: Select * from users WHERE upper(lastName) = upper('Pringle') Message-ID: <20030114113447.H5335@mail.libertyrms.com> References: <3E10825A.9000608@meinl.bnv-bamberg.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from halepringle@yahoo.com on Fri, Jan 10, 2003 at 06:45:43PM -0500 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/170 X-Sequence-Number: 6020 On Fri, Jan 10, 2003 at 06:45:43PM -0500, Hale Pringle wrote: > I have notices that when you want to use the upper() function, you must also > use the trim(). No. But. . . > For example, > In a situation where a column names lastname is char(40): > SELECT * FROM users WHERE lastname = 'Pringle' returns one row. > > SELECT * FROM users WHERE UPPER(lastname) = UPPER('Pringle') will return > zero rows. > > SELECT * FROM users WHERE TRIM(UPPER(lastname) = TRIM(UPPER('Pringle')) > will return one row. > > This seems odd to me. Can someone explain? . . .yes. The problem has to so with the char() data type, which is padded per spec. So if you do anything on it, you need to trim() it. I believe there is a special case in place in the spec just for the SELECTs, but someone more familiar with the specification can help. If you don't really need exactly 40 characters, use varchar() or text(). A -- ---- Andrew Sullivan 204-4141 Yonge Street Liberty RMS Toronto, Ontario Canada M2P 2A8 +1 416 646 3304 x110