For writing MySQL query to get all the tables having a particular column name, we can use LIKE operator. It can be understood with the help of an example as follows −
Example
Following is the MySQL query to get all the tables having columns name ‘ID’ in it −
mysql> Select Column_name as 'ColumnName',Table_name As 'Tablename' FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%ID%' ORDER BY Tablename LIMIT 10; +-------------+---------------+ | ColumnName | Tablename | +-------------+---------------+ | id | arena | | id | arena1 | | ID | cars | | ID | COLLATIONS | | ID | copy_cars | | COUNTRY_ID | countries | | REGION_ID | countries | | Customer_Id | customers | | Customer_Id | customer_view | | id | emp | +-------------+---------------+ 10 rows in set, 0 warnings (0.15 sec)