UPDATE `Starcraft2uvsu`
SET IF(`Starcraft2uvsu`.username = 'wasd', 'report1', 'report2') = 'Win'
FROM `Starcraft2uvsu`
WHERE `Starcraft2uvsu`.username = 'wasd'
錯誤phpMyAdmin是隨地吐痰是...MySQL的更新錯誤
#1064 - 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
'If(Starcraft2uvsu.username = wasd, 'report1', 'report2') = 'Win' FROM Starcraft2' at line 1
它甚至有可能通過if語句來設置列名?我想那是殺手。
的神奇查詢爲答案和註釋的組合..
UPDATE Starcraft2uvsu
SET report1 = CASE WHEN Starcraft2uvsu.username = 'wasd' THEN 'win' ELSE report1 END,
report2 = CASE WHEN Starcraft2uvsu.username <> 'wasd' THEN 'win' ELSE report2 END
WHERE Starcraft2uvsu.username = 'wasd' OR Starcraft2uvsu.username2 = 'wasd'
UPDATE'Starcraft2uvsu' SET報告1 = IF(用戶名= 'WASD',「贏」, '報告2'), 報告2 = IF(用戶名= 'WASD',報告2, '贏')FROM'Starcraft2uvsu'其中username = 'WASD' 給 #1064 - 你在你的SQL錯誤句法;檢查與您的MySQL服務器版本相對應的手冊,以便在第3行的'FROM'Starcraft2uvsu' WHERE username ='wasd''處使用正確的語法 我討厭SQL:P – Jamie
from子句不屬於更新聲明。 – ysth
我也有點困惑你的where子句;你想根據用戶名更新不同的列,但你選擇一個特定的用戶名? – ysth