技术文章和资源

技术文章(时间排序)

热门类别

Python PHP MySQL JDBC Linux

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

mysqlmysqli database

以下是 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)

相关文章