I hope someone can help me out. I have a table that logs our import jobs. I need a query that will produce a matrix with the names of tables on the vertical axis, the import dates on the horizontal axis, and the total number of records imported for that table on that date in the matrix cell. I don't care if we have to create a temporary table, but the whole thing must be done in MySQL.
Below is a simplified sample of our event log table. Not only does it have many more fieds, but we import many more tables. Therefore, the solution should account for querying the table names. You will notice that data can be imported into a table more than once per day, as in records 5 and 6.
id table_name import_date num_recs
----+-----------+--------------------+-------
0 customer 2010-06-20 00:00:00 10
1 order 2010-06-20 00:00:00 15
2 customer 2010-06-21 00:00:00 5
3 order 2010-06-21 00:00:00 6
4 customer 2010-06-22 00:00:00 1
5 order 2010-06-22 00:00:00 6
6 order 2010-06-22 00:00:00 1
We are looking for a result something like this. It does not have to be exact
table_name 06-20 06-21 06-22
------------+-----+-----+------
customer | 10 | 5 | 1
order | 15 | 6 | 7