 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I query for all the tables having a particular column name?
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)
Advertisements
 