SQL:更新查询错误值用于列

发布于 2024-09-28 17:47:58 字数 429 浏览 0 评论 0原文

我有一个更新记录的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最笨的告白 2024-10-05 17:47:58

如果变量是字符串,SQL 需要用单引号将其引起来:

waspdb = '$waspdb'

否则,它将在源行中查找名称为 $wasdb 的值的列。示例查询可能最清楚地说明了原因:

update YourTable set col1 = 2*col2

这将 col2 乘以 2;它不会将 col1 设置为 '2*col2' :)

If the variable is a string, SQL requires single quotes around it:

waspdb = '$waspdb'

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:

update YourTable set col1 = 2*col2

This multiplies col2 by 2; it doesn't set col1 to '2*col2' :)

零度℉ 2024-10-05 17:47:58

它可能是一个字符串字段或 varchar,您需要将其放在单引号中。像这样:

$tsql = "UPDATE cplinktable SET bmsid = $bmsid, autotaskid = $autotaskid, waspdb = '$waspdb', cpid = $cpid WHERE id = $id"

Its a string field or varchar probably and you need it in single quotes. Like this:

$tsql = "UPDATE cplinktable SET bmsid = $bmsid, autotaskid = $autotaskid, waspdb = '$waspdb', cpid = $cpid WHERE id = $id"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文