利按数据库表名规则命名读取表名称

SELECT
    substring_index(substring_index(`TABLES`.TABLE_NAME, '$', 2), '$', -1)+0 as dist_id,
    substring_index(`TABLES`.TABLE_NAME, '$', -1)+0 as y_m,
    TABLE_NAME as table_name
FROM information_schema.`TABLES`
WHERE `TABLE_SCHEMA` = 'apply_log'
having y_m = '2010' and dist_id not in (96)
order by dist_id, y_m
 

你可能感兴趣的:(数据库)