查询当前数据库所有表
select table_name from information_schema.tables where table_schema=‘数据库名’ and table_type=‘base table’
查询存在某个字段的表
SELECT DISTINCT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = ‘列名’ AND TABLE_SCHEMA=‘数据库名’
使用group_concat 格式化查出来的值:
select group_concat(concat('"',table_name,'"')) from information_schema.tables where table_schema='tiger2';
SELECT DISTINCT group_concat(concat('"',table_name,'"')) FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'book_id' AND TABLE_SCHEMA='tiger2';