2017-06-22 109 views
0

我有2個表需要更新的基礎上2條款 我包括一個第三個表,將其他2個表一起加入。我不能得到任何工作。PHP MySQL多個更新

UPDATE (list INNER JOIN Players ON list.Team_ID = Players.Players_Team_ID) INNER JOIN Users ON list.Team_ID = Users.User_Team_ID 
SET 
Players.Players_Team_ID = 6, Users.users_bank = users_bank-15000000, list.transfers = list.transfers+1 
WHERE Users.User_ID=14 AND Players.Players_ID=3; 

而不必更新第三表這將是

UPDATE (list INNER JOIN Players ON list.Team_ID = Players.Players_Team_ID) INNER JOIN Users ON list.Team_ID = Users.User_Team_ID 
SET 
Players.Players_Team_ID = 6, Users.users_bank = users_bank-15000000 
WHERE Users.User_ID=14 AND Players.Players_ID=3; 

誰能幫助我得到這個工作?

回答

1

您可以使用update-join語法更改您的查詢,如下所示,但我不明白爲什麼您需要JOIN與其他表。你UPDATE聲明可能是單個或單獨的更新以及

UPDATE list,Players,users 
INNER JOIN Players ON list.Team_ID = Players.Players_Team_ID 
INNER JOIN Users ON list.Team_ID = Users.User_Team_ID 
SET Players.Players_Team_ID = 6, 
Users.users_bank = users_bank - 15000000, 
list.transfers = list.transfers + 1 
WHERE Users.User_ID=14 
AND Players.Players_ID=3; 
+0

更新列表,播放器,用戶 INNER JOIN球員list.team_id = players.players_team_id INNER JOIN用戶ON list.team_id = users.user_team_id SET球員.players_team_id = 5, users.users_bank = users_bank - 200000 WHERE users.user_id = 29 和players.players_id = 2 MySQL表示:文件 #1066 - 不唯一的表/別名: '玩家' 這是我得到當我嘗試它 – Dan