List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:January 6 2007 5:00pm
Subject:Re: How to access an array variables in a single query
View as plain text  
In the last episode (Jan 06), VenuGopal Papasani said:
> On 1/6/07, ViSolve DB Team <mysqlsupport@stripped> wrote:
> >>   I have got an array variable say a[]={"i1","i2",i3""} now i need
> >> to get the values from the database that matches i1,i2,i3 for
> >> example
> >>
> >> select * from tablename where i1=a[1]  and
> >>
> >> simillaryly to a[2] and a[3] but my list is too big one more
> >> option i can write it through loop but it takes time.Is there any
> >> possibility of writing a single query to retrieve all that data.
> >
> >IN operator will do.
> >
> >For Instance.
> >
> >SELECT * FROM TABLE1 WHERE id IN ('i1','i2','i3');
> >From: "VenuGopal Papasani" <venu.papasani@stripped>
>
> but that is not static for 3 variables what if array contains 1000
> elements in cannot be used in such cases

It actually does work, as long as your total query length is less than
max_allowed_packet (defaults to 1048576 bytes).  An IN clause with 1000
elements and 10 characters per element would only be 13000 bytes. 

-- 
	Dan Nelson
	dnelson@stripped
Thread
How to access an array variables in a single queryVenuGopal Papasani6 Jan
  • Re: How to access an array variables in a single queryViSolve DB Team6 Jan
    • Re: How to access an array variables in a single queryVenuGopal Papasani6 Jan
      • Re: How to access an array variables in a single queryDan Nelson6 Jan
      • RE: How to access an array variables in a single queryJerry Schwartz8 Jan
        • Re: How to access an array variables in a single queryBrent Baisley8 Jan
          • RE: How to access an array variables in a single queryJerry Schwartz8 Jan
  • Re: How to access an array variables in a single queryViSolve DB Team6 Jan