MySQL 子查询在 MySQL 4.0 上失败并出现无效语法错误

发布于 2024-09-09 08:08:30 字数 767 浏览 7 评论 0原文

我正在 MySQL 4.0.30 上运行一个非常基本的子查询。
我的目标是从 mysql.user 表中获取对特定数据库具有授权的任何用户的用户权限,如 mysql.db 表中所述。查询如下所示:

mysql> select * from mysql.user where User IN 
   (select User from mysql.db where Db='db_name')\G

如您所见,它非常基本并且遵循 MySQL 手册中的子查询语法。但是,当我执行该命令时,它会出现以下响应错误:

ERROR 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 'select
User from mysql.db where Db='db_name')' at line 1

我还尝试使用 = ANY 而不是 IN 执行该命令。我在 4.1 和 5.0 版本的 MySQL 上运行了相同的查询。对此的任何帮助或见解表示赞赏。谢谢

I'm running a pretty basic subquery on MySQL 4.0.30.
My goal is to get the user permissions from the mysql.user table for any user with grants on a specific database, as noted in the mysql.db table. The query looks like this:

mysql> select * from mysql.user where User IN 
   (select User from mysql.db where Db='db_name')\G

As you can see, it's pretty basic and follows the subquery syntax in the MySQL manual. However, when I execute that, it errors with the following response:

ERROR 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 'select
User from mysql.db where Db='db_name')' at line 1

I also tried the command with = ANY instead of IN. I've run the same query on 4.1 and 5.0 versions of MySQL. Any help or insight on this is appreciated. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぺ禁宫浮华殁 2024-09-16 08:08:30

好吧,事实证明我只是没有仔细检查手册:

从 MySQL 4.1 开始,支持 SQL 标准所需的所有子查询形式和操作,以及一些特定于 MySQL 的功能。

http://dev.mysql.com/doc/refman/4.1/ zh/subqueries.html

Ok, so it turns out I just didn't check the manual closely enough:

Starting with MySQL 4.1, all subquery forms and operations that the SQL standard requires are supported, as well as a few features that are MySQL-specific.

http://dev.mysql.com/doc/refman/4.1/en/subqueries.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文