I have a database with well over 90 tables and I am trying to figure which, if any, of them have the same two specific columns. The code I am looking for would be something like this:
SHOW TABLES IN `database`
WHERE co开发者_StackOverflow中文版lumn = 'columnA'
AND column = 'columnB';`
Is this even possible?
This will give you all tables having either of the two columns, which you can browse through to find what you need.
select *
from information_schema.columns
where column_name in ('columnA', 'columnB')
order by table_name, column_Name
SELECT TABLE_SCHEMA AS `schema`, TABLE_NAME AS `table`, COLUMN_NAME AS `column`
FROM `information_schema`.`COLUMNS`
WHERE COLUMN_NAME IN('column1','column2')
精彩评论