mysql: What is the right syntax for NOT LIKE?

后端 未结 3 1271
后悔当初
后悔当初 2020-12-15 22:19

Hi I am trying to show tables with names not like a pattern by mysql is throws an error:

SHOW TABLES  NOT LIKE  \"tree%\";

returns:

相关标签:
3条回答
  • 2020-12-15 22:51

    According to this feature request, this has been introduced in mySQL 5.0.3. However, people there disagree, and it doesn't work in my 5.1.41 installation, either.

    I guess the answer is it's not possible.

    0 讨论(0)
  • 2020-12-15 22:59

    LIKE and NOT LIKE are used with SELECT statements. I don't think this works with the SHOW TABLES command.

    0 讨论(0)
  • 2020-12-15 23:07

    You could use the WHERE clause extension, as in:

    SHOW TABLES WHERE `Tables_in_<DatabaseName>` NOT LIKE 'tree%';
    

    This is supported on MySQL ≥5.0.

    Reference:

    • 12.4.5.39. SHOW TABLES Syntax.
    • 20.28. Extensions to SHOW Statements.
    0 讨论(0)
提交回复
热议问题