Вопрос

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