Обсуждение: How to Make Case InSensitive???

Поиск
Список
Период
Сортировка

How to Make Case InSensitive???

От
"S.Ramaswamy"
Дата:
When I use SQL statements, how can I make it case insensitive. If I
use

    SELECT * FROM series WHERE NAME='India'

I want to select rows including those where NAME='INDIA' / NAME =
'india'
and so on.

Can someone help me in the above??

Regards

S.Ramaswamy


Re: [SQL] How to Make Case InSensitive???

От
David Hartwig
Дата:

S.Ramaswamy wrote:

> When I use SQL statements, how can I make it case insensitive. If I
> use
>
>     SELECT * FROM series WHERE NAME='India'
>
> I want to select rows including those where NAME='INDIA' / NAME =
> 'india'
> and so on.
>
> Can someone help me in the above??

     SELECT * FROM series WHERE upper(NAME) = 'INDIA'
                            or
     SELECT * FROM series WHERE NAME ~* '^india$'


Re: [SQL] How to Make Case InSensitive???

От
Marcio Macedo
Дата:
Hey...

How does this " ~* " operator works ?!?!?!


David Hartwig wrote:
>
>
>      SELECT * FROM series WHERE upper(NAME) = 'INDIA'
>                             or
>      SELECT * FROM series WHERE NAME ~* '^india$'

--Marcio Macedo
    Conectiva

Re: [SQL] How to Make Case InSensitive???

От
David Hartwig
Дата:

Marcio Macedo wrote:

> Hey...
>
> How does this " ~* " operator works ?!?!?!
>
> David Hartwig wrote:
> >
> >
> >      SELECT * FROM series WHERE upper(NAME) = 'INDIA'
> >                             or
> >      SELECT * FROM series WHERE NAME ~* '^india$'

>

I don't use it myself, but it is a case insensitive regular expression
match operator.    "~' is the case sensitive operator.    Do "\do" in
psql to see all the operators.