目標是爲一行數據搜索兩個相似的表格。在2個表格中搜索唯一條目,然後更改數據
UPDATE
regusers_test AS rt
INNER JOIN
alt_toon_test AS att
ON
att.`toonname` = rt.`toonname`
SET
rt.`server` = CASE WHEN rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon' THEN '$server' ELSE rt.`server`
att.`server` = CASE WHEN att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon' THEN '$server' ELSE att.`server`
WHERE
(
rt.`username`='$user' AND rt.`server`='$oserver' AND rt.`toonname`='$otoon'
)
OR
(
att.`username`='$user' AND att.`server`='$oserver' AND att.`toonname`='$otoon'
)
但我不斷收到:
You have an error in your SQL syntax; check the manual that corresponds to your mySQL server version for the right syntax to use near 'att.'server'=Case When att.'username'='$user'...
我做了很多的谷歌搜索在週末,但沒有找到一個解決方案。希望這裏有人知道發生了什麼。
你需要你想設置的兩個字段之間用逗號? – andrewsi
迴應您的查詢。我相信這些錯誤會很明顯。 – Strawberry