views:

31

answers:

1

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

+1  A: 

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

desertwebdesigns