如上標題填充數據,我想從一個表中插入值到另一個困難來自另一個表
我跟着在這裏建議的答案, Need to populate one table with data from another table in same database
MySQL的代碼止跌回升
INSERT INTO `profitdb`(`BetID`, `PlayerID`, `PlayerWL`) SELECT `betdb`.`BetID`, `betdb`.`PlayerID`,`betdb`.`BetAmount` FROM `betdb` LEFT OUTER JOIN `profitdb` ON `betdb`.`BetID` = `profitdb`.`BetID`
,但我遇到這個錯誤
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
'SELECT `betdb`.`BetID`, `betdb`.`PlayerID`,`betdb`.`BetAmount` FROM `betdb`
LE' at line 3
這可能是我的錯嗎?
你的查詢是錯誤的,你不需要部分'VALUES(....)' –
既可以使用'VALUES'或'SELECT'作爲'INSERT',而不是兩者,除此之外,你正在使用''betdb ''在你的'FROM'和'JOIN'中沒有別名,爲其中至少一個引入一個別名 – DrCopyPaste
如果你做一個選擇插入你不需要值 – Daniele94