MySQL 中 NOT LIKE 的正确语法是什么?
MySQL 中 NOT LIKE 的正确语法如下:
SHOW TABLES WHERE `TABLES_IN_yourDatabaseName` NOT LIKE ‘yourTableName%’;
为了理解上述语法,我们将使用一个名为 SAMPLE 的数据库,其中包含一些表格。首先,我们将显示示例数据库的所有表格,然后再使用上述语法。
以下是显示所有表格的查询。首先使用 USE 命令切换到 SAMPLE 数据库:
mysql> USE SAMPLE;
Database changed
显示数据库中所有的表格。查询语句如下:
mysql> show tables;
以下是输出:
+--------------------------+
| Tables_in_sample |
+--------------------------+
| blobsizedemo |
| insert_prevent |
| insertrecord_selecttable |
| insertrecordprevent |
| mytable |
| newlinedemo |
| notequaloperator |
| sumofeverydistinct |
| yourtable |
+--------------------------+
9 rows in set (0.00 sec)
现在可以使用以上语法来查询所有表格名称中不包含“insert”文本的表格。查询语句如下:
mysql> show tables where `TABLES_IN_sample` NOT LIKE 'insert%';
以下是输出:
+--------------------+
| Tables_in_sample |
+--------------------+
| blobsizedemo |
| mytable |
| newlinedemo |
| notequaloperator |
| sumofeverydistinct |
| yourtable |
+--------------------+
6 rows in set (0.00 sec)
阅读更多:MySQL 教程
极客教程