If it's completely arbitrary I think you are stuck with using union unless it's an order that you might know beforehand. Then you can add an extra column with the index.
/Jonas On Sat, Oct 18, 2008 at 7:05 PM, Andrew Gatt <[EMAIL PROTECTED]> wrote: > Jonas Sandman wrote: >> Just to point out the obvious, have you tried ORDER BY? >> >> "SELECT name FROM table ORDER BY name;" will return your list in >> alphabetical order. >> >> /Jonas >> >> > Thanks for the suggestion, but it needs to be an order i can specify, > not just ordered. I.e. i may want row 45 first, then 32 then 67 etc... > >> On Sat, Oct 18, 2008 at 6:53 PM, Andrew Gatt <[EMAIL PROTECTED]> wrote: >> >>> Andrew Gatt wrote: >>> >>>> I'm not sure if i'm missing something, but is there an efficient way of >>>> retrieving multiple rows based on different conditions in order. For >>>> example i have a table with rows of ids, i want to select multiple rows >>>> at a time. At present i am doing a "SELECT name FROM table WHERE id = x" >>>> for each row i want and then stitching it all together. But i'm finding >>>> this is quite slow even on a moderately small database (2000 entries). >>>> >>>> I'm guessing my SQL is the worst way of doing things so i've been trying >>>> to find a better method. I stumbled across "SELECT name FROM table WHERE >>>> id IN (x,y,z) however this doesn't allow me to specify the order the >>>> rows are returned, which i must have. >>>> >>>> The only other option i can find is using UNION ALL in between multiple >>>> SELECT statements, but would this give me a large performance increase >>>> over doing this progammatically as i've got it? >>>> >>>> Unless i've missed something obvious which could well be the case! >>>> >>>> >>>> >>>> >>> After trying several methods to improve the SQL the only thing that >>> really made a difference was creating an index on the ids. Using a UNION >>> ALL did improve matters, but you end up have to concatenate a very long >>> string for the query, so if anyone does have any SQL ideas i'd like to >>> hear them. >>> >>> Andrew >>> >>> > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users