Only show tables with certain patterns in MySQL “show tables”?



You can use LIKE operator with show tables to display tables with certain pattern. The LIKE is used to set the pattern.

The syntax is as follows -

SHOW TABLES LIKE ‘yourPattern’;

We have the database test and there are some tables with the letter d. Therefore, the pattern we are considering is with d.

Now implement the above syntax to display tables with certain patterns in SHOW TABLES. The query is as follows.

mysql> show tables like '%d_';

The following is the output.

+----------------------+
| Tables_in_test (%d_) |
+----------------------+
| differenceinseconds  |
| lasthourrecords      |
| skiplasttenrecords   |
+----------------------+
3 rows in set (0.04 sec)

Advertisements