Skip to content

Instantly share code, notes, and snippets.

@mateusg
Created April 17, 2011 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mateusg/924582 to your computer and use it in GitHub Desktop.
Save mateusg/924582 to your computer and use it in GitHub Desktop.
MySQL query to search for columns by name in a database
-- MySQL Query
-- Search all tables from a database for columns that the name matches 'user_id'.
SELECT table_name, column_name FROM information_schema.columns
WHERE table_schema = 'database_name' AND column_name LIKE '%user_id%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment