Mysql更新多表查询

时间:2016-05-06 20:58:04

标签: mysql

我有3个表的select JOIN语句,我想知道UPDATE语句应该是什么。

SELECT candidates.CandidateName, candidates.CandidateVotes, candidates.Party, mainrace.MainRaceName, race.RaceName, candidates.win, candidates.NameOrder
FROM candidates
JOIN race ON race.RaceID = candidates.RaceID
JOIN mainrace ON mainrace.MainID = candidates.MainID
ORDER BY mainrace.MainRaceName'

我有类似的东西,我猜这是一团糟:)

$sql = "update candidates set candidates.CandidateName='$CandidateName',candidates.CandidateVotes='$CandidateVotes',candidates.Party='$Party',candidates.win='$win' ,candidates.NameOrder='$NameOrder' where candidates.CandidateID=$CandidateID"; 

感谢您的时间和帮助。

此致

1 个答案:

答案 0 :(得分:0)

语法应为:

Update  candidates join ... set