Reputation: 77
SQLITE DATABASE IS IN BELOW FORMAT:
Below TABLES are there DataModel File
_1011_105
_1011_106
_1011_107
and so on
and the _1011_106 (format of tables _1011) have below Columns (like ID,MODEL etc).
I did Below query search for searching all the tables in SqLiteDatabase
select name FROM sqlite_master where tbl_name like '%$_1011%' ESCAPE '$'
But I need to run one more query from the result of above query From above query I got all the names like
_1011_2
_1011_106
_1011_107
Hence I need to run query on these list like
Select * FROM (on each element of list I got from above query) WHERE MODEL='4001'
How this can be done in nested way?
Something like
select * from (select name FROM sqlite_master where tbl_name like '%$_1011%' ESCAPE '$');
Upvotes: 0
Views: 832
Reputation: 180070
SQLite has no mechanism to create dynamic SQL.
You have to read the list of table names first, and then construct a compound query like this in your program:
SELECT ...
FROM (SELECT * FROM _1011_105
UNION ALL
SELECT * FROM _1011_106
...)
WHERE Model = '4001';
Upvotes: 1