pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
newbie question * compare integer in a "where IN" statement
5+ messages / 3 participants
[nested] [flat]

* newbie question * compare integer in a "where IN" statement
@ 2011-07-12 12:50  Jose Ig Mendez <jmendez@andago.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Jose Ig Mendez @ 2011-07-12 12:50 UTC (permalink / raw)
  To: pgsql-sql

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

Á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 <http://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.

Attachments:

  [image/gif] logo-blanco.gif (2.8K, ../../4E1C4322.5030001@andago.com/3-logo-blanco.gif)
  download | view image

  [image/jpeg] medio-ambiente.jpg (1.2K, ../../4E1C4322.5030001@andago.com/4-medio-ambiente.jpg)
  download | view image

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* newbie question * compare integer in a "where IN" statement
@ 2011-07-13 07:36  Jose Ig Mendez <jmendez@andago.com>
  parent: Jose Ig Mendez <jmendez@andago.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Jose Ig Mendez @ 2011-07-13 07:36 UTC (permalink / raw)
  To: pgsql-sql


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

Á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 <http://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.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: newbie question * compare integer in a "where IN" statement
@ 2011-07-13 07:47  Thomas Kellerer <spam_eater@gmx.net>
  parent: Jose Ig Mendez <jmendez@andago.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Thomas Kellerer @ 2011-07-13 07:47 UTC (permalink / raw)
  To: pgsql-sql

Jose Ig Mendez, 13.07.2011 09:36:
>
> 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 ?

Just leave out the quotes:

select *
from myTable
where id_integer IN (1,2,3,4)




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: newbie question * compare integer in a "where IN" statement
@ 2011-07-13 07:50  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Jose Ig Mendez <jmendez@andago.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Pavel Stehule @ 2011-07-13 07:50 UTC (permalink / raw)
  To: Jose Ig Mendez <jmendez@andago.com>; +Cc: 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@andago.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.
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: newbie question * compare integer in a "where IN" statement
@ 2011-07-13 12:33  Jose Ig Mendez <jmendez@andago.com>
  parent: Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Jose Ig Mendez @ 2011-07-13 12:33 UTC (permalink / raw)
  To: pgsql-sql; +Cc: Pavel Stehule <pavel.stehule@gmail.com>

Hi,

Thank you very much Pavel, that solves my problem

Regards

On 13/07/11 09:50, Pavel Stehule wrote:
> 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@andago.com <mailto:jmendez@andago.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
>
>     Á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 <http://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.
>
>

-- 
------------------------------------------------------------------------

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

Á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 <http://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.

Attachments:

  [image/gif] logo-blanco.gif (2.8K, ../../4E1D907F.6030908@andago.com/3-logo-blanco.gif)
  download | view image

  [image/jpeg] medio-ambiente.jpg (1.2K, ../../4E1D907F.6030908@andago.com/4-medio-ambiente.jpg)
  download | view image

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2011-07-13 12:33 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-07-12 12:50 newbie question * compare integer in a "where IN" statement Jose Ig Mendez <jmendez@andago.com>
2011-07-13 07:36 ` Jose Ig Mendez <jmendez@andago.com>
2011-07-13 07:47   ` Thomas Kellerer <spam_eater@gmx.net>
2011-07-13 07:50   ` Pavel Stehule <pavel.stehule@gmail.com>
2011-07-13 12:33     ` Jose Ig Mendez <jmendez@andago.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox