What I want to do is duplicate his permissions to another user.
Permission table has:
id (PK)
userID (FK)
module
action
When I do an insert and do a select of the values of the first user, it says It cannot use the target table in the FROM clause.
Query:
Expand|Select|Wrap|Line Numbers
- INSERT INTO permission
- ( userID,
- module,
- pageAction)
- VALUES
- ( 28,
- "reportModule",
- (SELECT pageAction FROM permission WHERE userID = 19)
- );
- ERROR 1093 (HY000): You can't specify target table 'permission' for update in FROM clause
What's interesting is the Manual is very confusing, observe these statments from the manual: http://dev.mysql.com/doc/refman/5.0/...rt-select.html
[HTML]
# The target table of the INSERT statement may appear in the FROM clause of the SELECT part of the query. (This was not possible in some older versions of MySQL.) In this case, MySQL creates a temporary table to hold the rows from the SELECT and then inserts those rows into the target table.
# Currently, you cannot insert into a table and select from the same table in a subquery.
# To avoid ambiguous column reference problems when the SELECT and the INSERT refer to the same table, provide a unique alias for each table used in the SELECT part, and qualify column names in that part with the appropriate alias.
[/HTML]
Dan