Why doesn't this work? - SHOW TABLES NOT LIKE 'history%'

Hi,

Well my question is simple - I want to exclude tables with a certain prefix using this:

SHOW TABLES NOT LIKE ‘history%’

With the prefix obviously being ‘history’. I cannot understand why I get a nasty syntax error - it works when I have just LIKE rather than NOT LIKE but I want all the tables that are NOT like it.

Thanks.

SHOW TABLES is not part of sql, it’s a mysql-proprietary command

you just have to live with the fact that they didn’t include NOT in the SHOW TABLES syntax

Is there any way in MySQL to do the same thing?

do the same thing as what you wanted to do?

yes, if you’re on 5.0+ you can query the “tables” table with a WHERE clause

SELECT table_name FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = ‘the_db_name’
AND table_name NOT LIKE ‘history%’;