Subject Re: Is LIKE case sensitive?
Author Adam
--- In firebird-support@yahoogroups.com, "William Gonzáles S."
<wgonzaless@y...> wrote:
>
> Hello, I have several queries with `LIKE', but the
> results are not good for me, for example:
>
> SELECT NAME FROM SOME_TABLE WHERE (NAME LIKE '%hou%')
>
> It gives me records with: "house", "penthouse"
> but records: "House", "HOUSE", "PENTHOUSE" are
> ignored; I need a non case sensitive `LIKE', how can I
> solve this?
>
> Thanks in advance,
> William GS
>

William,

There are two similar functions LIKE and CONTAINING. LIKE is case
sensitive, CONTAINING is insensitive.

Take your pick, these two are equivalent:

SELECT NAME FROM SOME_TABLE WHERE (UPPER(NAME) LIKE UPPER('%hou%'))

SELECT NAME FROM SOME_TABLE WHERE (NAME CONTAINING 'hou')

The advantage of using like (apart from being able to be case
sensitive), is that expressions of the form 'hou%' are internally
optimised to a STARTING WITH, which is in turn able to use an index to
quickly return results.

Adam