P Kishor wrote:
> 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.
>
>   
I was under the impression i could create a temp view from all the
attached databases?

CREATE TEMP VIEW my_view AS SELECT * FROM database0.table UNION ALL
SELECT * FROM database1.table;

Although this is untested and i'm willing to accept if its wrong.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to