SQL:更新查询错误值用于列
我有一个更新记录的 PHP sql 命令。
$tsql = "UPDATE cplinktable SET bmsid = $bmsid, autotaskid = $autotaskid, waspdb = $waspdb, cpid = $cpid WHERE id = $id";
我收到错误:
Invalid column name 'WaspTrackAsset_SFT'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name 'WaspTrackAsset_SFT'. ) )
是否有某种原因将 waspdb 的值用作列?
谢谢,
琼斯
I have a PHP sql command that updates a record.
$tsql = "UPDATE cplinktable SET bmsid = $bmsid, autotaskid = $autotaskid, waspdb = $waspdb, cpid = $cpid WHERE id = $id";
I'm getting an error:
Invalid column name 'WaspTrackAsset_SFT'. [message] => [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid column name 'WaspTrackAsset_SFT'. ) )
Is there some reason that the value of waspdb is being used as a column?
thanks,
Jonesy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果变量是字符串,SQL 需要用单引号将其引起来:
否则,它将在源行中查找名称为
$wasdb
的值的列。示例查询可能最清楚地说明了原因:这将
col2
乘以2
;它不会将col1
设置为'2*col2'
:)If the variable is a string, SQL requires single quotes around it:
Otherwise, it will look in the source row for a column with the name of the value of
$wasdb
. The reason why is perhaps most clearly illustrated with an example query:This multiplies
col2
by2
; it doesn't setcol1
to'2*col2'
:)它可能是一个字符串字段或 varchar,您需要将其放在单引号中。像这样:
Its a string field or varchar probably and you need it in single quotes. Like this: