Attach historical data to a non-historical table

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.

Upvotes: 0

Views: 60

Answers (1)

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.

Upvotes: 1

Related Questions