On Tue, Jan 12, 2010 at 04:12:01PM -0500, Qianqian Fang scratched on the wall:
> On 1/12/2010 4:08 PM, Jay A. Kreibich wrote:
>> SELECT group_concat( value ) FROM mydata WHERE id IN ( 'id_1', 'id_2', ... )
>
> thank you very much for your quick response. I guess this will be
> significantly faster than looping through each id.

> One more question, will this work if you have a long list of ids (say
> a few hundred)?

  Yes, but it might not be fast, and the SQL gets very messy.

  If the set of IDs that you need is somewhat static, it might be best
  to load them into a temp table and then just join your data able to
  that id table.  You might end up inserting them one at a time, but if
  you use a prepared insert and bind statements, it should be pretty
  fast.

  Also, be aware that the order of the values is random.  If you use an
  IN statement, the order of the values has no relation to the order of
  the IDs.  Similar things can be said with the JOIN.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to