Обсуждение: newbie question * compare integer in a "where IN" statement

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

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

От
Jose Ig Mendez
Дата:
<br /> Hi everybody,<br /><br /> I'm trying to compare in a sentence like this (using PostGres 8.3) :<br /><br />
select* from myTable where id_integer IN ('1,2,3,4')<br /><br /> I want to get the records which key "id_integer" is 1
or2 or 3 or 4. the type od my "id", of course, is integer.<br /><br /> I've tried many differents ways but I cannot get
theresult I want. <br /> I would like to cast the integer parameter I cannot change the part after "IN" it has to be a
"stringlist".<br /><br /> Do I have to use a function ? I would like not to use it.<br /><br /> How can I compare a key
(integer)with a lists of values ?<br /><br /> I'm desperate<br /><br /> THANX IN ADVANCE<br /><br /><div
class="moz-signature">--<br /></div><hr style="color: #0c62b7; font-weight: bold; margin=0; padding:0" /><div
class="vcard"style="font-family: Arial, Sans; font-size: 9pt; color:#666;       margin: 0; padding: 0;"><p class="fn n"
style="color:#0c62b7;font-weight: bold; margin: 0; padding:         0"><span class="given-name">José Ignacio</span>
<spanclass="additional-name">Méndez Yanes</span><p class="note" style="color:#f8c454; font-weight: bold; margin: 0;
padding:        0">Área de Operaciones / Area of Operations<p style="margin: 0; padding: 0">Phone: <span class="tel"
style="font-weight:bold; color: #333;">+34 916 011 373</span> / <span class="tel" style="font-weight: bold; color:
    #333;">+34 946 416 066</span><p style="margin: 0; padding: 0">Mobile: <span class="tel" style="font-weight: bold;
color:#333;">+34 666 431 099</span><p style="margin: 0; padding: 0">Fax: <span style="font-weight:           bold;
color:#333;">+34 916 011 372</span> / <span style="font-weight: bold; color: #333;">+34 944 318 286</span><table
style="border:none; margin: 0; padding: 0; font-size:         8pt"><tbody><tr style="margin: 0; padding: 0;"><td><img
align="left"alt="Ándago" class="org" height="72" hspace="1" src="cid:part1.05000903.03020905@andago.com" vspace="3"
width="120"/></td><td><span class="adr" style="color: #333;"><span class="street-address">Alcalde Ángel Arroyo 10, 1ª
Planta</span>.<span class="postal-code">28904</span>. <span class="locality">Getafe</span>, <span
class="region">Madrid</span></span><br/><span class="adr" style="color: #333;"><span class="street-address">Kanala
Bidea,Edif. 103, 1ª Izda. Parque Tecnológico</span>. <span class="postal-code">48170</span>. <span
class="locality">Zamudio</span>,<span class="region">Bizkaia</span></span><br /><span class="nombre"><a class="url"
href="http://www.andago.com"moz-do-not-send="true" style="color:#0c62b7; text-decoration:                   none;
font-weight:bold;">www.andago.com</a></span></td></tr></tbody></table></div><p style="margin: 0; padding: 0;"><span
style="font-size:8pt;">Síguenos en: <a href="http://twitter.com/andago" moz-do-not-send="true" style="color:#0c62b7;
      text-decoration: none; font-weight: bold;">Twitter</a> - <a
href="http://www.facebook.com/pages/Andago/111911732048"moz-do-not-send="true" style="color:#0c62b7;
text-decoration:none; font-weight: bold;">Facebook</a> - <a href="http://www.linkedin.com/groups?gid=1479457"
moz-do-not-send="true"style="color:#0c62b7;           text-decoration: none; font-weight: bold;">LinkedIn</a> - <a
href="http://www.youtube.com/andagotv"moz-do-not-send="true" style="color:#0c62b7;           text-decoration: none;
font-weight:bold;">YouTube</a></span><table style="border: none;"><tbody><tr><td width="30"><img align="left" alt=""
height="20"hspace="1" src="cid:part2.07080008.01000509@andago.com" vspace="3" width="30" /></td><td><span class="arbol"
style="font-size:9pt; color:#038000;">Antes de imprimir este mensaje, asegúrese de que es necesario. Consider the
environmentbefore printing this mail.</span></td></tr></tbody></table><p style="color:#0c62b7; font-size: 7pt;
font-weight:bold;       text-align: center; margin: 0; padding: 0">AVISO LEGAL<hr style="color:#0c62b7; margin: 0;
padding:0" /><p style="font-size: 7pt; margin: 0; padding: 0"><b>ANDAGO CONSULTING SL / ANDAGO INGENIERÍA, SL</b> le
informaque los datos facilitados por Ud. y utilizados para el envío de esta comunicación serán objeto de tratamiento
automatizadoo no en nuestros ficheros, con la finalidad de gestionar la agenda de contactos de nuestra empresa y para
elenvío de comunicaciones profesionales por cualquier medio electrónico o no. Vd. podrá en cualquier momento ejercer el
derechode acceso, rectificación, cancelación y oposición en los términos establecidos en la Ley Orgánica 15/1999. El
responsabledel tratamiento es ANDAGO CONSULTING SL / ANDAGO INGENIERIA SL, con domicilio en C/ ALCALDE ANGEL ARROYO,
10,28904, Getafe (Madrid).<p style="font-size: 7pt; margin: 0; padding: 0">El contenido de esta comunicación, así como
elde toda la documentación anexa, es confidencial y va dirigido únicamente al destinatario del mismo. En el supuesto de
queusted no fuera el destinatario, le solicitamos que nos lo indique y no comunique su contenido a terceros,
procediendoa su destrucción. <p style="color:#0c62b7; font-size: 7pt; font-weight: bold;       text-align: center;
margin:0; padding: 0">DISCLAIMER<hr style="color:#0c62b7; margin: 0; padding: 0" /><p style="font-size: 7pt; margin: 0;
padding:0">The content of this communication and any attached information is confidential and exclusively for the use
ofthe addressee. If you are not the addressee, we ask you to notify to the sender and do not pass its content to
anotherperson, and please be sure you destroy it.  

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

От
Thomas Kellerer
Дата:
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)



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

От
Pavel Stehule
Дата:
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

ÁndagoAlcalde Á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 - Facebook - LinkedIn - YouTube

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.


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

От
Jose Ig Mendez
Дата:
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>

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

ÁndagoAlcalde Á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 - Facebook - LinkedIn - YouTube

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

ÁndagoAlcalde Á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 - Facebook - LinkedIn - YouTube

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.

Вложения