Re: Consulta de un valor en varios campos

From: Miguel Angel Hernandez Moreno <miguel(dot)hdz(dot)mrn(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Lista PostgreSql <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Consulta de un valor en varios campos
Date: 2013-08-15 15:21:02
Message-ID: CAGYOd3rNTWWYTCG6DkjQft5FU3zuNWhkEe74RNqmf5fQO6V9GA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Ok

eh intentado con el array pero me marca un pequeño error

SELECT * from tabla_valores
where camp1 = ANY (
select ARRAY[val1, val2, val3, val4] FROM tabla_ datos )

-----------------------------------------------------------------------------------------------------------------
ERROR: operator does not exist: numeric = numeric[]
LINE 4: camp1 = ANY (select ARRAY[val1, val2, val3...
^
HINT: No operator matches the given name and argument type(s). You might
need to add explicit type casts.

********** Error **********

ERROR: operator does not exist: numeric = numeric[
-----------------------------------------------------------------------------------------------------------------

ya trate de verlo haciendo un cast a numeric[]
pero marca error tambien, si alguien le a pasado algo asi les agradeceria
mucho

Muchas gracias por su ayuda!! :D

El 14 de agosto de 2013 15:55, Alvaro Herrera
<alvherre(at)2ndquadrant(dot)com>escribió:

> > Y se hace una consulta similar de la siguiente manera
> >
> > select * from tabla_valores
> > where camp1 in(
> > select val1 from tabla_ datos union
> > select val2 from tabla_ datos union
> > select val3 from tabla_ datos union
> > select val4 from tabla_ datos
> > )
>
> Uh. Yo intentaría hacer algo con
> WHERE camp1 = ANY (ARRAY[val1,val2...])
> donde la obvia dificultad es asegurarse que se usen los índices
> pertinentes.
>
> --
> Álvaro Herrera http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Training & Services
>

--
ISC Miguel Angel Hernandez Moreno

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Hiram Israel Villalobos Manriquez 2013-08-15 16:25:23 Reunión del Grupo de Usuarios de pgSQL en México en Guadalajara, Jal.
Previous Message Felipe Araoz Ramos 2013-08-15 14:23:15 Re: Pasar como parametros campo y tabla a SP