Subject | Re: Facing Problem with limitations of IN CLAUSE |
---|---|
Author | Ali Gökçen |
Post date | 2006-03-09T08:32:29Z |
Hi Kapil,
I dislike such type kamikaze queries but anyway,
sometimes we need it..
(for example, fetch some rows from large tables on day and month
values using index. bithday list etc..)
Try this:
create view wt1 (id)
as
select id from t1 where id in(1,...,1499)
union all
select id from t1 where id in(1500,...,2998)
union all
select id from t1 where id in(3000,...,4997);
select x.grpfield,max(x.valuefield) from t1 x
join t1 y on y.id=x.id
group by 1
Regards.
Ali
--- In firebird-support@yahoogroups.com, "Kapil Patil"
<kapilpatil84firebird@...> wrote:
I dislike such type kamikaze queries but anyway,
sometimes we need it..
(for example, fetch some rows from large tables on day and month
values using index. bithday list etc..)
Try this:
create view wt1 (id)
as
select id from t1 where id in(1,...,1499)
union all
select id from t1 where id in(1500,...,2998)
union all
select id from t1 where id in(3000,...,4997);
select x.grpfield,max(x.valuefield) from t1 x
join t1 y on y.id=x.id
group by 1
Regards.
Ali
--- In firebird-support@yahoogroups.com, "Kapil Patil"
<kapilpatil84firebird@...> wrote:
>1499
>
> As per my knowledge I know that IN CLAUSE have limitations of only
> elements. (firebird v2.0)therefore
>
> I have one query where IN CLAUSE elements exceeds above 4000
> firebird gives error...elements in
>
> I tried entering the elements in temp. table and then using the
>
> SELECT ........ from TABLENAME where ...... in (Select .. from
> TEMPTABLE)
>
> It works, but quiet slow because I have to first insert the
> TEMP TABLE andor ... in
> then fire the main query as shown above.
>
> I Also tried using combination of IN and OR Operator as
>
> select ... from tablename where .. in (1,2,3,4,5,6....,1499)
> (1500.......) or ... in(.......)records
>
> But this works very very slow taking around 8 to 10 minutes and
> sometimes even more, so not very effective query
>
> Some one suggested me to break the query in two or more
> like first 1499 elements in one query and then fire and get the
> and thenapproach
> next 1499 elements and get the records and so .. on
>
> but the problem is that I want to order by clause and with this
> it is not possible to sort the data....MIN
> and secondly If query contains aggregate functions like SUM, MAX,
> ..... in that casewrong
> firing query with first 1499 elements and so..on will give me
> resultscreating any
>
> SO, Is there any way to overcome this limitations with out
> TEMP TABLE
>
> Thanks In advance,
>
> Kapil Patil
>
>
>
>
>
>
> [Non-text portions of this message have been removed]
>