MySQL 子查询在 MySQL 4.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,事实证明我只是没有仔细检查手册:
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:
http://dev.mysql.com/doc/refman/4.1/en/subqueries.html