• support@answerspoint.com

How to find all the tables in MySQL with specific column names in them?

1738

I have 2-3 different column names that I want to look up in the entire DB and list out all tables which have those columns. Any easy script?

1Answer


0

To get all tables with columns 'columnA' or 'ColumnB' in the database 'YourDatabase'

SELECT DISTINCT TABLE_NAME 
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE COLUMN_NAME IN ('columnA','ColumnB')
        AND TABLE_SCHEMA='YourDatabase';
  • answered 8 years ago
  • Sandy Hook

Your Answer

    Facebook Share        
       
  • asked 9 years ago
  • viewed 1738 times
  • active 9 years ago

Best Rated Questions