mysql> SHOW TABLES like 'cms'; +-------------------------+ | Tables_in_tianyan (cms) | +-------------------------+ | cms | +-------------------------+ 1 row in set (0.00 sec)
Result
mysql> SHOW TABLES like 'cms' or like 'role'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual...
How can I filter by multiple conditions ?
The SQL LIKE clause is used to compare a value to similar values using wildcard operators. There are two wildcards used in conjunction with the LIKE operator. The percent sign represents zero, one or multiple characters. The underscore represents a single number or character.
To select multiple values, you can use where clause with OR and IN operator.
With SQL, you can get information from columns in more than one table. This operation is called a join operation. In SQL, a join operation is specified by placing the names of those tables that you want to join in the same FROM clause of a SELECT statement.
Use the \dt or \dt+ command in psql to show tables in a specific database.
You need to use the WHERE
clause. As shown in the docs, you can only have a single pattern if you use "SHOW TABLES LIKE ..."
, but you can use an expression in the WHERE clause if you use "SHOW TABLES WHERE ..."
. Since you want an expression, you need to use the WHERE
clause.
SHOW TABLES FROM `<yourdbname>` WHERE `Tables_in_<yourdbname>` LIKE '%cms%' OR `Tables_in_<yourdbname>` LIKE '%role%';
You can just use a normal SQL WHERE
statement to do it.
SHOW TABLES WHERE Tables_in_tianyan LIKE '%cms%'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With