必要な情報を正確に把握できるように、より多くの情報を提供する必要がありますが、ビューを作成することもできます
CREATE VIEW myViewName AS
select *
from table1
union all
select * from
table2
このようにして、すべてのテーブルからの情報が表示され(すべてを表示しないように選択で制限できます)、table1、table2などが変更されると、ビューにこれが反映されます。テーブルと同じように、いつでも変更してフェッチできます。
select * from myViewName
特定のテーブルから取得するために、tsqlで実行しましたが、mysqlでこれを実行する方法がわかりません。この前の質問はあなたを助けるので、あなたは次のようなものを持っているかもしれません:
-- Create temporary table of varchar(200) to store the name of the tables. Depending on how you want to go through the array maybe an id number (int).
insert into tempTableName (name)
SELECT table_name FROM information_schema.tables WHERE table_schema = 'database_name' and table_name like 'TX_%';
declare @sqlQuery varchar(max)
--Then you will want to loop through the array and build up an sql statement
-- For each loop through:
if len(@sqlQuery) = 0 begin -- first time through
set @sqlQuery = 'select col1, col2, col3 from ' + currentTableName
end else begin -- second+ time through
set @sqlQuery = 'union all select col1, col2, col3 from ' + currentTableName
end
-- after the loop add the create view. Could double check it worked by checking length = 0 again
set @sqlQuery = 'CREATE VIEW myViewName AS ' + @sqlQuery
Once the query string is built up you will execute it with
PREPARE stmt FROM @sqlQuery;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;