Is it possible to select from show tables
in MySQL?
SELECT * FROM (SHOW TABLES) AS `my_tables`
Something along these lines, th
You can create a stored procedure and put the table names in a cursor, then loop through your table names to show the data.
Getting started with stored procedure: http://www.mysqltutorial.org/getting-started-with-mysql-stored-procedures.aspx
Creating a cursor: http://www.mysqltutorial.org/mysql-cursor/
For example,
CREATE PROCEDURE `ShowFromTables`()
BEGIN
DECLARE v_finished INTEGER DEFAULT 0;
DECLARE c_table varchar(100) DEFAULT "";
DECLARE table_cursor CURSOR FOR
SELECT table_name FROM information_schema.tables WHERE table_name like 'wp_1%';
DECLARE CONTINUE HANDLER
FOR NOT FOUND SET v_finished = 1;
OPEN table_cursor;
get_data: LOOP
FETCH table_cursor INTO c_table;
IF v_finished = 1 THEN
LEAVE get_data;
END IF;
SET @s=CONCAT("SELECT * FROM ",c_table,";");
PREPARE stmt FROM @s;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END LOOP get_data;
CLOSE table_cursor;
END
Then call the stored procedure:
CALL ShowFromTables();