Find all where column value exist in an array (no loop?)

I would like to find all records from a table where a column value exist
in an array…
like this

@city_array = [‘125’, ‘459’, ‘748’,… ‘9654’, ‘12459’] # can be over
500 id’s
@condition = [‘WHERE city_id IN ?’, @city_array]
@proposals = Proposals.find (:all, :condition => @condition)

if this set of values is small , that’s fine, but when the array size is
big, it can explode the string size limit of the where clause…

or I can loop over the array ids, but so long… performance…

any suggestions ?

thanks

kad

On Dec 19, 2006, at 12:19 AM, Kad K. wrote:

kad
Did the array (@city_array) values come from the database? If so,
you can probably do better letting the database do the JOIN. Post a
bit more code and you might get more help. (The relevant schema and
models might help, too.)

-Rob

Rob B. http://agileconsultingllc.com
[email protected]