gpt4 book ai didi

mysql - 使用 where 子句更新 MySQL

转载 作者:行者123 更新时间:2023-11-29 05:00:38 26 4
gpt4 key购买 nike

我正在尝试更新用户名 = $username 的字段

UPDATE userinfo SET password = $newpass WHERE username = $username

但是,当我替换 $username 时,出现错误“#1054 - ‘where 子句’中的未知列‘bob’”与 bob .

知道如何正确编写吗?

最佳答案

啊哈!在您发表评论后,很明显您没有将文本用引号引起来:

UPDATE userinfo SET password = $newpass WHERE username = '$username'

由于 $username 是一个文本值,您需要在它周围加上单引号,以便 SQL 将其解析为文本,而不是列。

关于mysql - 使用 where 子句更新 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1292015/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com