I have below list of tables which is created based on weekly archive.
dbtable
dbtable_01_04_2017
dbtable_01_07_2017
dbtable_02_09_2017
dbtable_03_06_2017
dbtable_05_08_2017
dbtable_06_05_2017
dbtable_08_04_2017
dbtable_08_07_2017
dbtable_09_09_2017
dbtable_10_06_2017
dbtable_12_08_2017
dbtable_13_05_2017
dbtable_15_04_2017
dbtable_15_07_2017
dbtable_17_06_2017
dbtable_19_08_2017
dbtable_20_05_2017
dbtable_22_04_2017
dbtable_22_07_2017
dbtable_24_06_2017
dbtable_26_08_2017
dbtable_27_05_2017
dbtable_29_04_2017
dbtable_29_07_2017
All of them has the exact same column structure:
TIME_STAMP, USERNAME, INFO, CAUSE
I need to query all of them at once using the same query, of course only by changing the table name in below example query.
SELECT * FROM dbtable WHERE USERNAME="XXXX";
I googled a bit hoping that there is a way to wildcard the name in the query but I learned that SQL doesn't support that.
Basically, I am looking for some kind of for loop to iterate the query to multiple tables.
Please note that new tables will be added each week based on our archive automation.