mysql:不喜欢的正确语法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3698891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 17:09:10  来源:igfitidea点击:

mysql: What is the right syntax for NOT LIKE?

syntaxmysql

提问by Arman

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

嗨,我正在尝试显示名称与 mysql 模式不同的表会引发错误:

SHOW TABLES  NOT LIKE  "tree%";

returns:

返回:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT LIKE "tree%"' at line 1

What is the right syntax?

什么是正确的语法?

Thanks Arman.

谢谢阿尔曼。

回答by kennytm

You could use the WHERE clause extension, as in:

您可以使用 WHERE 子句扩展,如下所示:

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

This is supported on MySQL ≥5.0.

这在 MySQL ≥5.0 上受支持。

Reference:

参考:

回答by Andrew Vit

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

LIKE 和 NOT LIKE 与 SELECT 语句一起使用。我认为这不适用于 SHOW TABLES 命令。

回答by Pekka

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.

根据这个功能要求,这已经在mySQL 5.0.3中引入了。但是,那里的人不同意,而且它在我的 5.1.41 安装中也不起作用。

I guess the answer is it's not possible.

我想答案是不可能。