Friday, 14 March 2014

Get all tables with columns 'columnA' or 'ColumnB' in the database

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';

No comments:

Post a Comment

Note: only a member of this blog may post a comment.