How can I find all the tables in MySQL with specific column names in them?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When you need to find every MySQL table that contains a given column name, the right place to look is INFORMATION_SCHEMA.COLUMNS. That metadata table lets you query schema structure directly instead of inspecting tables one by one.
Query INFORMATION_SCHEMA.COLUMNS
The most direct query is:
This returns every table, across all visible databases, where the column name matches exactly. It is useful when you are tracing a field during refactoring, auditing duplicated schema design, or checking migration impact.
Restrict the Search to One Database
In many cases, you only want matches from the current application schema. Add a TABLE_SCHEMA filter so the search stays focused.
This is usually the safer production query because it avoids unrelated system schemas and neighboring databases on the same server.
Search for Multiple Possible Column Names
Sometimes the real task is broader, such as finding every table that contains either created_at or updated_at. In that case, use IN.
This is helpful when normalizing legacy schemas or locating variant field names before a migration.
Find Tables That Contain All Required Columns
If you need tables that contain several columns together, group and count the matches.
That query answers a different question from simple presence. It finds tables that contain the full required set.
Use the Results for Follow-Up Inspection
After identifying candidate tables, you may want to inspect the full column layout to confirm types, keys, or nullability.
This helps when the same column name appears in several places but is not used consistently.
If you are exploring legacy schemas, it can also help to search with naming patterns such as LIKE '%_id' or LIKE 'created_%'. Exact-name searches are better for precision, but pattern searches are useful during discovery work.
A Practical Rule for Schema Discovery
For schema-discovery tasks, INFORMATION_SCHEMA should be your default tool. It is easier to automate, easier to review, and much safer than ad hoc manual inspection. Once the query is right, you can reuse it for documentation, migrations, and audit checks.
Common Pitfalls
- Forgetting to filter by
TABLE_SCHEMAand getting matches from unrelated databases. - Searching for one column name when the real requirement is a set of columns used together.
- Assuming the same column name implies the same type, nullability, or business meaning.
- Using table-by-table manual inspection instead of metadata queries.
- Ignoring case and naming conventions in mixed legacy schemas.
Summary
INFORMATION_SCHEMA.COLUMNSis the standard place to find MySQL tables by column name.- Add
TABLE_SCHEMAfilters to keep the results relevant. - Use
INto search for several column names andGROUP BYwithHAVINGto require a full set. - Follow up with column metadata inspection when names alone are not enough.
- Metadata queries are the cleanest way to explore schema structure in MySQL.

