Re: Select * from users WHERE upper(lastName) = upper('Pringle')

Поиск
Список
Период
Сортировка
Искать
От
Andrew Sullivan
Тема
Re: Select * from users WHERE upper(lastName) = upper('Pringle')
Дата
Msg-id
20030114113447.H5335@mail.libertyrms.com
Ответ на
Список
Дерево обсуждения
batch example "Campano, Troy" <Troy.Campano@LibertyMutual.com>
unsubscribe jrJAMES <migraine007ph@yahoo.com>
unsubscribe Rajesh Krishnamoorthy <raj_krishnamoorthy@yahoo.com>
Re: batch example Thorsten Meinl <Thorsten@meinl.bnv-bamberg.de>
Select * from users WHERE upper(lastName) = upper('Pringle') "Hale Pringle" <halepringle@yahoo.com>
Re: Select * from users WHERE upper(lastName) = Dave Cramer <Dave@micro-automation.net>
Re: Select * from users WHERE upper(lastName) = upper('Pringle') Andrew Sullivan <andrew@libertyrms.info>
Re: Select * from users WHERE upper(lastName) = upper('Pringle') Tom Lane <tgl@sss.pgh.pa.us>
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

В списке pgsql-jdbc по дате отправления
От: Andy Kriger
Дата:
Сообщение: Re: Using JDBC
От: Eric B.Ridge
Дата:
Сообщение: Re: Using JDBC
FAQ