2010/03/31

MySQL 如何在所有的 TABLES 當中尋找特定的欄位名稱

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

SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('columnA','ColumnB')
AND TABLE_SCHEMA='YourDatabase';

參考 : http://stackoverflow.com/questions/193780/how-to-find-all-the-tables-in-mysql-with-specific-column-names-in-them