使用grant时mysql子查询错误

时间:2013-02-25 12:59:24

标签: php mysql

MySQL运行此查询时出错:

mysqli_query($connect,"GRANT SELECT,INSERT ON myblog.*
    TO '$username'@'localhost' IDENTIFIED BY 
    (SELECT user_password from users where user_name = '$username')") 
or die("fail to grant ".mysqli_error($connect));

这个查询有什么问题?有没有更好的解决方案?

1 个答案:

答案 0 :(得分:0)

MySQL不支持外部语句为GRANT的子查询。

A subquery's outer statement can be any one of: SELECT, INSERT, UPDATE, DELETE, SET, or DO.

编辑:取自MySQL docs on subqueries