是什么导致了“MySQL 错误 #1054 - 未知列”?错误?
我在这个 MySQL 查询中遇到了一些问题。我已经使用了我在另一个问题中看到的建议,但仍然不起作用......
代码
$kernel->db->query( "UPDATE `" . TABLE_PREFIX . "users`
SET `total_downs` = `total_downs` + 1
WHERE `phcdl_files`.`file_author` = " . $file['file_author'] );
这是给出的
无效的 SQL 查询
“where 子句”中的未知列“phcdl_files.file_author”(MySQL 错误号;1054)
I'm having a little problem with this MySQL query. I've already used an suggestion I've seen in another question but still doesn't work....
Here's the code
$kernel->db->query( "UPDATE `" . TABLE_PREFIX . "users`
SET `total_downs` = `total_downs` + 1
WHERE `phcdl_files`.`file_author` = " . $file['file_author'] );
Which gives
Invalid SQL Query
Unknown column 'phcdl_files.file_author' in 'where clause' (MySQL error no; 1054)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这意味着表 phcdl_files 中不存在 file_author 列。您可能需要
编辑:请参阅上面拜伦·惠特洛克的评论。您通常不想将变量直接插入到 SQL 查询字符串中。
That means that the column file_author doesn't exist in the table phcdl_files. You probably want
EDIT: please see the comment by Byron Whitlock above. You generally don't want to insert a variable directly into a SQL query string.
如果
phcdl_files
是表的名称,则需要在查询中包含该表,并表达它与TABLE_PREFIXusers
中的行之间的某种关系> 您想要更新的内容。If
phcdl_files
is the name of a table, you need to include that table in your query, and express some relationship between it and the rows inTABLE_PREFIXusers
that you want to update.phcdl_files
.file_author
在哪里?和 $file['file_author'] 应来自 phcdl_files 表
where is
phcdl_files
.file_author
?and $file['file_author'] should come from phcdl_files table