我試圖從特定行的數據更新幾行幾行
這是一個表,ItemNum
是唯一
我嘗試:
SQL - 更新基於特定行
UPDATE myTable t, (SELECT DISTINCT width, repeat
FROM myTable
WHERE ItemNum='80644') t1
SET t.width = t1.width
AND SET t.repeat = t1.repeat
WHERE ItemNum='80645'
AND WHERE ItemNum='80646'
給我一個錯誤
#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 'FROM myTable WHERE ItemNum='80644') t1 SET t.width' at line 2
當我運行本作的單排它的工作原理
但多行的語法似乎是問題
UPDATE myTable t, (SELECT DISTINCT width
FROM myTable
WHERE ItemNum='80644') t1
SET t.width = t1.width
WHERE ItemNum='80645'
這有很多問題。你有沒有在這裏查找正確的語法:http://dev.mysql.com/doc/refman/5.0/en/update.html UPDATE table SET t.width = t1.width,t.repeat = t1.repeat WHERE t.ItemNum =#AND t.ItemNum =#; – Shawn 2012-08-06 18:48:46
你怎麼加入你的表?你可以顯示一些你的mysql模式? – Shawn 2012-08-06 18:52:25
爲什麼投票? – 2013-06-01 00:42:12