So within my database(r) I’ve got 5 tables(a,b,c,d,e) and I want to be able to show the amount of packets stored at the current time(created_at) with any combination of them on a graph…
-
I have a Custom variable for the table name($table_name):
r.a, r.b, r.c, r.d, r.e
and I have multi-select and all checked… -
Next I have a Custom variable with the column names($col_name):
a.created_at, b.created_at, c.created_at, d.created_at, e.created_at
and I have multi-select and all checked… -
So from there I constructed the following:
SELECT NOW() as time, count(${col_name:format}) as value, 'packets' as metric FROM ${table_name:format} GROUP BY 3
The column name I’m trying to return for each of the tables is named the same, it’s simply a created_at column and I’m just trying to take the count of it to return the number of data entries. When I left that select parameter as:
count(created_at) as value,
I was getting an error "column ‘created_at’ is ambiguous’ so I figured specifying the table name would fix this, but I’m continuing to just hit syntax errors… Am I missing something about the syntax of MySQL? Is this an issue with the language limitations? The issue came in with trying to use the variable in the SELECT statement for the value, aside from the “created_at is ambiguous” the FROM ${table_name:format} should be fine. Any help would be awesome.