MySQL Update Select usage instance
You should use the inner join, which is:
UPDATE Friends INNER JOIN users on Friends.friendid=users.userid SET friends.friendname=users.username
MySQL uses a temporary table to implement a nested query inside the FROM clause, then the nested query is loaded into another nested query, so that the FROM clause query and save are in the temporary tables, and then indirectly in the perimeter query is referenced.
Let's look at the following SQL statement:
Update apples
Set price = (
Select Price from (
SELECT * from apples
) as X
where variety = ' Gala ')
where variety = ' Fuji ';
Continue to look at the following two examples
Update a set a.xx= (select yy from B) where a.id = b.ID;
However, in MySQL, you cannot use the result of a set select directly, you must use the INNER join:
Update a INNER join (select yy from B) C on a.id =b.id set a.xx = C.yy
The following is a classic MySQL UPDATE statement assignment nested Select instance
Update mem_player set ' datawarehouse ' = (select ' Datawarehouse ' from (SELECT * from Mem_player) as B where ' Pid ' =100000)
Note : More wonderful articles please pay attention to the triple programming Tutorial column.