From: Robert Klemme Date: 2006-12-19T21:00:15+09:00 Subject: Re: string of strings... On 19.12.2006 10:23, Josselin wrote: > On 2006-12-19 09:29:38 +0100, "Martin DeMello" > said: > >> On 12/19/06, Josselin wrote: >>> I got an array of id's : >>> >>> ids = [22443, 22468, 22371, 22218, 22472, 22377, 22245] >>> >>> I would like to get a string of strings (to be used in SQL WHERE..IN >>> clause >>> >>> " '22443' , ' 22468' , ' 22371' , ' 22218' , '22472' , '22377' , >>> '22245' " >>> >>> If a use ids.join(','), I get >>> "22443,22468,22371,22218,22472,22377,22245" which is obviously not >>> useful for SQL.... >> >> ids.map {|i| "'#{i}'"}.join(" ,") >> >> martin > > thanks Martin... I realize that the error I got was not due to integers > list , "22443, 22468, 22371, 22218, 22472, 22377, 22245" is accepted... > so the join(',') is ok.. > but the list is too long ... for a select statement.. (I can have 50 > numbers or more.....) there is a characters limit to the select Maybe you can generate ranges for adjacent values. IIRC we had a thread here at some point in the past - maybe it's even a quiz. A completely different option is to create a temp table (depends on your DB whether and how that is done), put all the values in that temp table and join it against the table you are querying. Kind regards robert