Re: newbie question * compare integer in a "where IN" statement

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jose Ig Mendez <jmendez(at)andago(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: newbie question * compare integer in a "where IN" statement
Date: 2011-07-13 07:50:51
Message-ID: CAFj8pRCxb5PkQC7FBps4AJtwLZ4WsKxc1SLsg1P5Dqh4oAZZnw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

you can try

SELECT .. FROM .. WHERE id = ANY(string_to_array('1,2,3,4,5',','))

other forms are slow

Regards

Pavel Stehule

2011/7/13 Jose Ig Mendez <jmendez(at)andago(dot)com>

>
> Hi everybody,
>
> I'm trying to compare in a sentence like this (using PostGres 8.3) :
>
> select * from myTable where id_integer IN ('1,2,3,4')
>
> I want to get the records which key "id_integer" is 1 or 2 or 3 or 4. the
> type od my "id", of course, is integer.
>
> I've tried many differents ways but I cannot get the result I want.
> I would like to cast the integer parameter I cannot change the part after
> "IN" it has to be a "string list".
>
> Do I have to use a function ? I would like not to use it.
>
> How can I compare a key (integer) with a lists of values ?
>
> I'm desperate
>
> THANX IN ADVANCE
>
> --
> ------------------------------
>
> José Ignacio Méndez Yanes
>
> Área de Operaciones / Area of Operations
>
> Phone: +34 916 011 373 / +34 946 416 066
>
> Mobile: +34 666 431 099
>
> Fax: +34 916 011 372 / +34 944 318 286
> [image: Ándago] Alcalde Ángel Arroyo 10, 1ª Planta. 28904. Getafe,
> Madrid
> Kanala Bidea, Edif. 103, 1ª Izda. Parque Tecnológico. 48170. Zamudio,
> Bizkaia
> www.andago.com
>
> Síguenos en: Twitter <http://twitter.com/andago> - Facebook<http://www.facebook.com/pages/Andago/111911732048>-
> LinkedIn <http://www.linkedin.com/groups?gid=1479457> - YouTube<http://www.youtube.com/andagotv>
> Antes de imprimir este mensaje, asegúrese de que es necesario.
> Consider the environment before printing this mail.
>
> AVISO LEGAL
> ------------------------------
>
> *ANDAGO CONSULTING SL / ANDAGO INGENIERÍA, SL* le informa que los datos
> facilitados por Ud. y utilizados para el envío de esta comunicación serán
> objeto de tratamiento automatizado o no en nuestros ficheros, con la
> finalidad de gestionar la agenda de contactos de nuestra empresa y para el
> envío de comunicaciones profesionales por cualquier medio electrónico o no.
> Vd. podrá en cualquier momento ejercer el derecho de acceso, rectificación,
> cancelación y oposición en los términos establecidos en la Ley Orgánica
> 15/1999. El responsable del tratamiento es ANDAGO CONSULTING SL / ANDAGO
> INGENIERIA SL, con domicilio en C/ ALCALDE ANGEL ARROYO, 10, 28904, Getafe
> (Madrid).
>
> El contenido de esta comunicación, así como el de toda la documentación
> anexa, es confidencial y va dirigido únicamente al destinatario del mismo.
> En el supuesto de que usted no fuera el destinatario, le solicitamos que nos
> lo indique y no comunique su contenido a terceros, procediendo a su
> destrucción.
>
> DISCLAIMER
> ------------------------------
>
> The content of this communication and any attached information is
> confidential and exclusively for the use of the addressee. If you are not
> the addressee, we ask you to notify to the sender and do not pass its
> content to another person, and please be sure you destroy it.
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jose Ig Mendez 2011-07-13 12:33:03 Re: newbie question * compare integer in a "where IN" statement
Previous Message Thomas Kellerer 2011-07-13 07:47:38 Re: newbie question * compare integer in a "where IN" statement