
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Query All 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