On Mon, Sep 28, 2009 at 12:06 PM, Andrew Gatt <[email protected]> wrote: > I'm trying to optimise a select statement, but from multiple attached > databases. The general statement would be; > > SELECT * FROM database0.table WHERE id = 1; > > Where i have a long list of ids to retrieve, which could be from any of > the attached databases. With a single database i would prepare the > statement and bind to the id value, but from what i understand i can't > do this for the database name? Something like; > > SELECT * FROM :database.table WHERE id = :id;
You can't bind the value of a database and table. > > If that can't work is it worth creating some kind of view out of all the > attached databases and running a prepared statement on the view? Or > should i just leave it as multiple select statements! How would that help? You would have to create multiple views, one for each database, and you would be back to the same problem as before. The best is to just code up your select statements in your application, and use bind values for each one of them. Or, write code to generate the multiple select statements for you automatically. > > Thanks, > > Andrew > > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science ======================================================================= Sent from Madison, WI, United States _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

