Mega Search
23.2 Million


Sign Up

Make a donation  
Rows into columns  
News Group: comp.databases.informix

We have a query with a huge lists of ID's in an IN list......such as SELECT * WHERE id IN(id1, id2, id3.....id1400) list.

Is there a way  to change it so that the  the big "IN" lists could be changed so that the "IN" list was populated into a temp table first and then joined to to the rest of the query.

i.e.  In the query below, it would change to "select * from a into temp mytemp"

with a(mycol) as (values('a'),('b'),('c')) 
select * from a

 MYCOL
 -----
 a
 b
 c



thanks in advance.

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 30-Sep-2014, at 1:17 PM EST
From: m
 
Re: Rows into columns  
News Group: comp.databases.informix
On Tuesday, 30 September 2014 21:17:00 UTC+1, tom...@gmail.com  wrote:
> We have a query with a huge lists of ID's in an IN list......such as SELECT * WHERE id IN(id1, id2, id3.....id1400) list.
> 
> 
> 
> Is there a way  to change it so that the  the big "IN" lists could be changed so that the "IN" list was populated into a temp table first and then joined to to the rest of the query.
> 
> 
> 
> i.e.  In the query below, it would change to "select * from a into temp mytemp"
> 
> 
> 
> with a(mycol) as (values('a'),('b'),('c')) 
> 
> select * from a
> 
> 
> 
>  MYCOL
> 
>  -----
> 
>  a
> 
>  b
> 
>  c
> 
> 
> 
> 
> 
> 
> 
> thanks in advance.

Use an external file?

create temp table tmp_ids (id integer) with no log;

load from "id_file" insert into tmp_ids;

select * from TABLE where id in (select id from tmp_ids);

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 3-Oct-2014, at 8:11 AM EST
From: armsiee