I'm looking for a straight way to run a query on all databases hosted on my mysql server.
I have a bunch of Magento installations and I want to truncate all Magento log table on all databases:
- log_customer
- log_visitor
- log_visitor_info
- log_url
- log_url_info
- log_quote
- report_viewed_product_index
- report_compared_product_index
- report_event
- catalog_compare_item
I think it something very easy to accomplish in mysql but I cannot find a straight answer/solution.
UPDATE
I'm interested in pure SQL approach ... so no PHP based solution are welcome
UPDATE 2 **UPDATE **
According to @Ollie Jones it is not possible to do it without a STORE PROCEDURE or a server side language ( PHP or whatever )
UPDATE 31
I choose to follow the PHP approach (@samitha) for 2 reasons:
- STORE PROCEDURE looks more complicated
- Query on 'information_schema' table is very slow ( at least if you have many DB/TABLES)