Skip to content

Instantly share code, notes, and snippets.

@selfish
Last active December 20, 2017 14:09
Show Gist options
  • Save selfish/8b5d7b96111379f64188 to your computer and use it in GitHub Desktop.
Save selfish/8b5d7b96111379f64188 to your computer and use it in GitHub Desktop.
Find MySQL Tables containing a column by name
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('columnA','ColumnB')
AND TABLE_SCHEMA='YourDatabase';
-- OR:
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%columnA%'
AND TABLE_SCHEMA='YourDatabase';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment