I have datewise data in 30 different tables. The names of the tables are as follows - wh_available_items.01/06/2022
, wh_available_items.02/06/2022
, and so on for the rest of the dates of the month of June.
I want to combine all these records in a single report. I can do that using the following query -
SELECT '1 June 2022', a.* FROM table1 AS a
UNION
SELECT '2 June 2022', b.* FROM table2 AS b
UNION
...
SELECT '30 June 2022', a4.* FROM table30 AS a4
I wanted to know if there's a way I could write a dynamic query that would generate a monthly report at the end of every month. So when a report is required for the month of July, it would integrate datewise tables for that month and create a similar report.
Thanks for helping!