MySQL Workbench 报告“对于此服务器版本在此位置无效”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53471882/
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 22:58:31  来源:igfitidea点击:

MySQL Workbench reports "is not valid at this position for this server version" error

mysqlmysql-workbench

提问by Theo Bouras

For the following SQL query:

对于以下 SQL 查询:

SELECT COUNT (distinct first_name) from actor;

I receive the following error message:

我收到以下错误消息:

"SELECT" is not valid at this position for this server version, expecting: '(', WITH

I am a total newbie at SQL. How do I resolve this error?

我是 SQL 的新手。如何解决此错误?

I put the exact same line at another PC with the exact same schema and it worked fine.

我在另一台具有完全相同架构的 PC 上放置了完全相同的行,并且运行良好。

回答by Gufus

Have you tried to run the query deleting the space between "COUNT" and the bracket? I run a similar query to yours on MYSQL 5.7 and it gives me an error, but without that space the query runs.

您是否尝试运行查询删除“COUNT”和括号之间的空格?我在 MYSQL 5.7 上运行了一个与你类似的查询,它给了我一个错误,但没有那个空间查询运行。

Let's try this:

让我们试试这个:

SELECT COUNT(DISTINCT first_name) FROM actor;

回答by Prashant Marathay

I know this isn't the exact problem you stated, but this was the same error message I was getting. The message is so generic that it could be anything...

我知道这不是您所说的确切问题,但这与我收到的错误消息相同。该消息是如此通用,以至于它可以是任何东西......

So, from one newbie to another:

所以,从一个新手到另一个:

For me, the error occurred when I nested one query within another. I had a ; at the end of the first query and forgot to take it out. That threw the error. Once I deleted the ; in the inner query and added one at the end of the new query the error resolved.

对我来说,当我将一个查询嵌套在另一个查询中时发生了错误。我曾有一个 ; 在第一次查询结束时忘记将其取出。那抛出了错误。一旦我删除了; 在内部查询中并在新查询的末尾添加一个,错误已解决。

Error:

错误:

Select
From (....
    Select
    From
    Where
    Group by
    Order ;     <== offending ;
) as ...
Where
Group by
Order

No Error:

没有错误:

Select
From (....
    Select
    From
    Where
    Group by
    Order
) as ...
Where
Group by
Order ;   <== correct placement

回答by Neeraj Bansal

Mine error resolved using 'db_name.' with table although I have already executed use 'db_name' command;

使用“db_name”解决了我的错误。尽管我已经执行了 use 'db_name' 命令;

select * FROM db_name.table_name;