Thursday, April 14, 2011

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

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

From stackoverflow
  • This works in SQL Server and i believe MySql has an 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'
    
    Tim Büthe : Yes, MySQL has that too and the Statement works fine, but why are you using "like" without any wildcard instead of "=" ?
    Town : Copy/pasted it from a quick test on our DB here where i was using a wildcard, fixed now - ta! :)

0 comments:

Post a Comment