我已经四处寻找我的问题的解决方案,但在网上看不到任何类似的东西。 我正在研究一个SQL脚本,以便在一行的第一个空列中插入值。
收到此MySQL错误:
错误:您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在'WHERE ID = 89'附近使用正确的语法。
这是我的剧本。通过尝试将52插入ID = 89的行中的第一个空列进行测试。
$item3 = 52;
$sql="insert into TABLENAME set
GAME1 = case when GAME1 = '' then $item3 else GAME1 end,
GAME2 = case when GAME2 = '' and GAME1 <> '' then $item3 else GAME2 end,
GAME3 = case when GAME3 = '' and GAME1 <> ''and GAME2 <> '' then $item3 else GAME3 end
WHERE ID = 89 ";
谢谢。
答案 0 :(得分:4)
使用update
$sql="update TABLENAME set
GAME1 = case when GAME1 = '' then $item3 else GAME1 end,
GAME2 = case when GAME2 = '' and GAME1 <> '' then $item3 else GAME2 end,
GAME3 = case when GAME3 = '' and GAME1 <> ''and GAME2 <> '' then $item3 else GAME3 end
WHERE ID = 89 ";