2

mysql: get all tables in database that have a column called xyz

1 Answer 1

7

Both SQL Server and MySql have the Information_Schema.Columns table: http://dev.mysql.com/doc/refman/5.1/en/columns-table.html

select c.table_name from 
information_schema.columns c 
where c.column_name = 'xyz'
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, MySQL has that too and the Statement works fine, but why are you using "like" without any wildcard instead of "=" ?
Copy/pasted it from a quick test on our DB here where i was using a wildcard, fixed now - ta! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.