SQL 在一行中的第一个空列中插入 MySQL 错误 [英] SQL Insert in first empty column in a row MySQL error
本文介绍了SQL 在一行中的第一个空列中插入 MySQL 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我四处寻找解决问题的方法,但在网上找不到任何类似的东西.我正在编写一个 SQL 脚本,以便在一行中的第一个空列中插入值.
I have looked around for a solution to my problem but can’t see anything similar online. I am working on an SQL script to insert values in the first null column in a row.
我收到此 MySQL 错误:
Am getting this MySQL error:
错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在WHERE ID = 89"附近使用的正确语法.
Error: 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 ' WHERE ID = 89 ' .
这是我的剧本.通过尝试将 52 插入 ID=89 的行中的第一个空列进行测试.
This is my script. Am testing by trying to insert 52 into the first empty column in the row with 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 ";
谢谢.
推荐答案
use 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 ";
这篇关于SQL 在一行中的第一个空列中插入 MySQL 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文