문제

I have two tables with a similar structure in MySQL, one is the updated data and other is the history records for that data, and I need to perform analytics over all data we have there. I thought using a view that aggregates all data in one table would be useful but I'm not sure how to accomplish it.

도움이 되었습니까?

해결책

Why not just create a view using UNION?

CREATE VIEW my_view AS
SELECT field1 AS f1, field2 AS f2 FROM table1
UNION
SELECT field1 AS f1, field2 AS f2 FROM table2

Then perform your analysis over that view.

More docs: UNION, CREATE VIEW.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top