I'm having trouble getting this query to work in mysql:
UPDATE proyects_c 
   SET director=(SELECT users.keyid 
                   FROM users,proyects 
                  WHERE users.username=proyects.director
                );
Now the problem is that the subquery returns more than one row. Thing is, this is what I want. The number of rows that it returns is the same as the number of rows in proyects_c, hence what I expected this to do is update every row in the column director with the result of the query.
However I get the error:
ERROR 1242 (21000) at line 23: Subquery returns more than 1 row
Which makes sense, but I can't get it to do what I want. What am I doing wrong?
As a secondary question, how can I split this into two queries? For clarity's sake.
 
     
     
    