Hi all,

I have multiple databases, both have a table called "lists" inside this
table is the names of other tables in the database that make up the
lists. Each individual list is made up of the tables that have the same
name in each database (the list is split between different storage
devices in this case).
e.g.

database 1
"lists" list_1, list_2
"list_1" item_1, item_2
"list_2" item_1, item_2

database 2
"lists" list_1, list_3
"list_1" item_3, item_4
"list_3" item_1,item_2

To get an output with all the lists of both databases i can use a union
command on the "lists" table:

select * from database1.lists union select * from database2.lists;

However if i'm not sure which approach to take to get the contents of a
specific list. I'm trying to replicate this sort of statement:

select * from database1.list_2 union all select * from database2.list_2;

but by my scheme you can't be sure if the list_1 table exists in
database2, which if i'm right will error the statement and provide no
output?
The other option is to run a set of statements first checking whether
the table exists and keeping a record of which database does and
building the statement that way, but this seems inelegant. I was hoping
someone would have seen this kind of behaviour before and could point me
in the right direction of a solution? All comments are welcome.

Thanks,
Andrew
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to