Consultas "case-insensitive"

Bruno Unna bruno@sac.com.mx
Fri, 12 Dec 1997 10:55:24 -0600


David Hinojosa wrote:
> 
> Una consulta:
> 
>         ¿Se puede hacer una consulta tipo "like" de modo que no tenga en cuenta
> si el texto está en mayúsculas/minúscular?
> 
> Gracias

Si, al comparar tus strings usa el operador ~*

Echale un ojo a la pagina de manual pgbuiltin, de la cual 
estoy recortando esto:

BINARY OPERATORS
       Operators:

       general
            <=                  less or equal
            <>                  inequality
            <                   less than
            <=                  greater or equal
            >=                  greater or equal
            >                   greater than
            =                   equality
            ~                   A matches regular expression B,
case-sensitive
            !~                  A does not match regular expression B,
case-sensitive
            ~*                  A matches regular expression B,
case-insensitive.
            !~*                 A does not match regular expression B,
case-insensitive
            ~~                  A matches LIKE expression B,
case-sensitive
            !~~                 A does not match LIKE expression B,
case-sensitive

PostgreSQL                   04/01/97                           7

PGBUILTIN(INTRO)            PostgreSQL           PGBUILTIN(INTRO)

            +                   addition
            -                   subtraction
            *                   multiplication
            /                   division
            %                   modulus
            @                           &<                  A overlaps
B, but does not extend to right of B
            &>                  A overlaps B, but does not extend to
left of B
            <<                  A is left of B
            >>                  A is right of B
            >^                  A is above B
            <^                  A is below B

       float8
            ^                   exponentiation
            %                   truncate to integer
            |/                  square root
            ||/                 cube root
            :                   exponential function
            ;                   natural logarithm (in psql, protect with
parentheses)

       point
            <<                  A is left of B
            >>                  A is right of B
            >^                  A is above B
            <^                  A is below B
            ~=                  A same as B (equality)
            @                   point inside (or on) path, box, circle,
polygon

       box
            &&                  boxes overlap
            &<                  box A overlaps box B, but does not
extend to right of box B
            &>                  box A overlaps box B, but does not
extend to left of box B
            <<                  A is left of B
            >>                  A is right of B
            >^                  A is above B
            <^                  A is below B
            =                   area equal
            <                   area less than
            <=                  area less or equal
            >=                  area greater or equal
            >                   area greater than
            ~=                  A same as B (equality)
            @                   A is contained in B
            ~                   A contains B
            @@                  center of box

PostgreSQL                   04/01/97                           8

PGBUILTIN(INTRO)            PostgreSQL           PGBUILTIN(INTRO)

       polygon
            &&                  polygons overlap
            &<                  A overlaps B but does not extend to
right of B
            &>                  A overlaps B but does not extend to left
of B
            <<                  A is left of B
     absolute value

       geometric
            @                   A contained by (inside or on) B
            ~                   A contains (around or on) B
            @@                  center of object
            <->                 distance between A and B
            &&                  objects overlap


Bueno, etc.

Saludos.

-- 
+-------------------------------------------------------+
|                                            Bruno Unna |
+------------------+--------------+---------------------+
| bruno@sac.com.mx | ICQ: 1858580 | Pub. Key by request |
+------------------+--------------+---------------------+