本文主要是介绍SQL-反向-模糊查询-Demo,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
总结: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%")
这篇关于SQL-反向-模糊查询-Demo的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!