Show MySQL tables starting with prefix?

mysql

Solution

To list all tables with some prefix, "any number of symbols" wildcard (`%`), should be used.

`_` is also a wildcard, representing any single symbol, and therefore it should be escaped.

Therefore, given your prefix is `someprefix_`, then

SHOW TABLES LIKE 'someprefix\_%'

would work

Problem

I'm trying to get MySQL tables by name starting with prefix `"someprefix_"`, but I get wrong (?) results. I tried to execute `SHOW COLUMNS LIKE 'someprefix_%'` but problem is, that I have also tables with prefix `"someprefix2_"` and those tables are also being returned in the result. Is there a way to exclude tables with a similar prefix from the result?

Original source