MySQL 中 NOT LIKE 的正确语法是什么?

MySQL 中 NOT LIKE 的正确语法是什么?

MySQL 中 NOT LIKE 的正确语法如下:

SHOW TABLES WHERE `TABLES_IN_yourDatabaseName` NOT LIKE yourTableName%’;
Mysql

为了理解上述语法,我们将使用一个名为 SAMPLE 的数据库,其中包含一些表格。首先,我们将显示示例数据库的所有表格,然后再使用上述语法。

以下是显示所有表格的查询。首先使用 USE 命令切换到 SAMPLE 数据库:

mysql> USE SAMPLE;
Database changed
Mysql

显示数据库中所有的表格。查询语句如下:

mysql> show tables;
Mysql

以下是输出:

+--------------------------+
| Tables_in_sample         |
+--------------------------+
| blobsizedemo             |
| insert_prevent           |
| insertrecord_selecttable |
| insertrecordprevent      |
| mytable                  |
| newlinedemo              |
| notequaloperator         |
| sumofeverydistinct       |
| yourtable                |
+--------------------------+
9 rows in set (0.00 sec)
Mysql

现在可以使用以上语法来查询所有表格名称中不包含“insert”文本的表格。查询语句如下:

mysql> show tables where `TABLES_IN_sample` NOT LIKE 'insert%';
Mysql

以下是输出:

+--------------------+
| Tables_in_sample   |
+--------------------+
| blobsizedemo       |
| mytable            |
| newlinedemo        |
| notequaloperator   |
| sumofeverydistinct |
| yourtable          |
+--------------------+
6 rows in set (0.00 sec)
Mysql

阅读更多:MySQL 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册