
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
What is the correct syntax for NOT LIKE in MySQL?
The following is the correcrt syntax for NOT LIKE in MySQL:
SHOW TABLES WHERE `TABLES_IN_yourDatabaseName` NOT LIKE ‘yourTableName%’;
To understand the above syntax, we will use the database SAMPLE which has some tables. First, we will display all tables of sample database. After that we will use the above syntax.
The query is as follows to display all tables. First switch the database to SAMPLE using USE command:
mysql> USE SAMPLE; Database changed
Display all tables from the database. The query is as follows:
mysql> show tables;
The following is the output:
+--------------------------+ | Tables_in_sample | +--------------------------+ | blobsizedemo | | insert_prevent | | insertrecord_selecttable | | insertrecordprevent | | mytable | | newlinedemo | | notequaloperator | | sumofeverydistinct | | yourtable | +--------------------------+ 9 rows in set (0.00 sec)
Now you can use above syntax to check all table names which does not have the text “insert” in it. The query is as follows:
mysql> show tables where `TABLES_IN_sample` NOT LIKE 'insert%';
The following is the output:
+--------------------+ | Tables_in_sample | +--------------------+ | blobsizedemo | | mytable | | newlinedemo | | notequaloperator | | sumofeverydistinct | | yourtable | +--------------------+ 6 rows in set (0.00 sec)
- Related Articles
- What is the use of MySQL NOT LIKE operator?
- Correct MySQL INSERT ... ON DUPLICATE KEY syntax?
- What is the syntax for input parameters (variables) in a MySQL query?
- What is correct syntax to create Python tuples?
- What is correct syntax to create Python lists?
- What is correct syntax to create Python dictionary?
- What is correct syntax of Python if statement?
- What is the syntax for boolean values in MongoDB?
- What is the syntax for lambda expressions in Java?
- What is the correct DateTime format for a MySQL Database?
- What is the syntax for leading bang! in JavaScript function?
- MySQL syntax not evaluating with not equal operator in presence of null?
- What is the syntax for defining the data structure in C++?
- What is basic syntax of Python for Loops?
- Use MySQL LIKE and NOT LIKE to display similar results?

Advertisements