Re: How does one perform a case-insenstive query on test

Поиск
Список
Период
Сортировка
От Steve Atkins
Тема Re: How does one perform a case-insenstive query on test
Дата
Msg-id CC2C1B80-BAFC-4504-B56C-3E3D76E18E1E@blighty.com
обсуждение исходный текст
Ответ на Re: How does one perform a case-insenstive query on test  (Erik Jones <erik@myemma.com>)
Ответы Re: How does one perform a case-insenstive query on  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-general
On Jan 10, 2007, at 12:18 PM, Erik Jones wrote:

> af300wsm@gmail.com wrote:
>> Hello,
>>
>> Well, the subject line pretty much says it all.  If any clarification
>> is needed, what I want to do is as follows:
>>
>> SELECT * FROM table WHERE thisfield = 'some text';
>>
>> How would I rewrite this query to search through the table looking at
>> the text in the column "thisfield" for the string "some text" but
>> have
>> it perform a case insensitive search?
>>
> SELECT * FROM table WHERE thisfield ilike 'some text';

Or SELECT * FROM table WHERE lower(thisfield) = lower('some text');

Which is less idiomatic than ilike, but has the advantage that
you can create a functional index on thisfield to allow the
query to use an index.

They'll both only search for an exact (but case-insensitive) match,
though - if what you're looking to do is look for any row where
thisfield contains 'some text' somewhere within it then that's an
entirely different thing and you'd want "... ilke '%some text%';"

Cheers,
   Steve

В списке pgsql-general по дате отправления:

Предыдущее
От: Erik Jones
Дата:
Сообщение: Re: How does one perform a case-insenstive query on test
Следующее
От: brian
Дата:
Сообщение: Re: Trying to load MySQL data