I have a mySQL database called listDB that contain several tables with column name Product etc. I want to SELECT from all tables where
You can get all tables that has column "Product" from information_Schema.columns
SELECT DISTINCT table_name FROM information_schema.columns WHERE column_name ="Product";
Nor create a procedure
delimiter //
CREATE PROCEDURE curdemo()
BEGIN
DECLARE a varchar(100);
DECLARE cur1 CURSOR FOR SELECT DISTINCT table_name FROM information_schema.columns WHERE column_name ="Product";
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO a;
SELECT * FROM a;
END LOOP;
CLOSE cur1;
END;
delimiter ;
call curdemo();