MySQL query Tables based on Timeframe

Hey everybody,

So I’m working with Grafana and MySQL to query some of my tables. My project has a lotta of data so what I’m doing is for each month I’m creating a new table on my DataBase. Kinda like:

January = Table1
February = Table 2
March = Table 3

What I would like is, when my user set his time interval on his dashboard Grafana will “grab” data from Table1 to return January’s values. Table 2 would return February’s values, Table 3 same thing and so forth.

I was thinking that it has to be a way to achieve that in Grafana… I just don’t know how… Maybe using variables?

If somebody could point me to the right direction I would appreciate.

Tks!

maybe try a union of all tables using common date and metric column

SELECT
UNIX_TIMESTAMP(t.date_column) as time_sec,

count(t.date_column) as value,

t.metric as metric

FROM
(
select date_column,count(date_column),metric from table1
union
select date_column,count(date_column),metric from table2
union
select date_column,count(date_column),metric from table1
) as t group by t.date_column,t.metric