Is there a way to select all the rows across all the tables where the column name matches a certain condition? I know how to select all tables that contain the given column name:
SELECT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'customer_id'
Is there a way to join tables using the table name pulled out? For example, something that works as this (clearly incorrect) query tries to.
SELECT * FROM (SELECT DISTINCT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'customer_id') WHERE customer_id = 1