← all notes

Find columns by name across the schema

· 1 min read

  • #database
  • #sql
  • #mysql

Here is one way to find which tables in a schema contain a certain column name in MYSQL.

SELECT COLUMN_NAME, TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME like '%mail%'
  AND TABLE_SCHEMA = 'company';

The results will look like this:

COLUMN_NAME TABLE_NAME
mail forms
mail_user forms
replymail shops