On Tue, Jan 12, 2010 at 04:00:51PM -0500, Qianqian Fang scratched on the wall:
> hi
> 
> My knowledge to sql is very limited. So forgive me if this sounds
> really simple to you. I want to do a lookup operation with sqlite:
> I have a table (id, value), where id is an index field, now I have
> a list of ids, and I want to retrieve their values from the database
> and separate them with ",".
> 
> I know I can do a loop: for each id, "select value from mydata where 
> id='id_i'"
> then concatenate the values after the loop. I somehow felt that
> this will be very slow. I am wondering if there is a command
> can do this lookup more efficiently.\

SELECT group_concat( value ) FROM mydata WHERE id IN ( 'id_1', 'id_2', ... )

   -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