Home:ALL Converter>get data from all tables having same column name and same data structure PHP MySql

get data from all tables having same column name and same data structure PHP MySql

Ask Time:2018-01-08T23:14:12         Author:CoderFriend

Json Formatter

Hello I have one MySql database with 4000 tables. All the tables have same data structure. I want to retrieve data from one column "name" which is inside all the tables. I want to list all that data.

I had searched through google, stack overflow and many more resources. But I don't find any specific answer to do this without join or union. As I don't want to write that 4000 names in query. Is there any general query to do it fast. I think that might be possible to get data using information schema table but I don't know how.

As I know how to select tables:

SELECT DISTINCT TABLE_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE COLUMN_NAME IN ('Product')
        AND TABLE_SCHEMA='YourDatabase';

But I don't know query to get data out of them. Thank You.

Author:CoderFriend,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48153058/get-data-from-all-tables-having-same-column-name-and-same-data-structure-php-mys
yy