总结:SQL-反向-模糊查询-Demo
SELECT table_name FROM information_schema.tables WHERE TABLE_SCHEMA=(SELECT DATABASE()) AND table_name
NOT IN (SELECT table_name FROM information_schema.tables WHERE TABLE_SCHEMA=(SELECT DATABASE()) AND table_name LIKE "%copy%" OR table_name LIKE "%bak%")
解析1:该 SQL查 所有 当前操作数据库的 表名
SELECT table_name FROM information_schema.tables WHERE TABLE_SCHEMA=(SELECT DATABASE())
解析2: 该 SQL模糊查询(包含“copy”,以及 包含“bak”)的表名
SELECT table_name FROM information_schema.tables WHERE TABLE_SCHEMA=(SELECT DATABASE()) AND table_name LIKE "%copy%" OR table_name LIKE "%bak%"
解析3: 该 SQL结合解析1和解析2的SQL,意思是,查所有表名,但不包含(NOT IN(解析2))解析2中的模糊查询结果集(子查询)
SELECT table_name FROM information_schema.tables WHERE TABLE_SCHEMA=(SELECT DATABASE()) AND table_name
NOT IN (SELECT table_name FROM information_schema.tables WHERE TABLE_SCHEMA=(SELECT DATABASE()) AND table_name LIKE "%copy%" OR table_name LIKE "%bak%")