MySQL更新语句:“字段列表"中的未知“表" [英] MySQL Update Statement: Unknown 'table' in 'field list'

查看:185
本文介绍了MySQL更新语句:“字段列表"中的未知“表"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用UPDATE时,一旦我按下GO,就会出现以下错误:

As soon as I am trying to use UPDATE, following error appears as soon as I hit GO:

1109-字段列表"中未知的表用户"

现在,由于我知道该表名并不是使用过的最好的唯一表,因此我尝试通过以下语句更具体一点:

Now since I knew that this table name is not the best and unique that has been used, I tried to get a little more specific with my statement:

UPDATE
    MyDatabase.user
SET
    MyDatabase.user.registeredAt = NOW()
WHERE
    MyDatabase.user.id = 3;

仍然是相同的错误.我在桌子周围用`或用phpmyadmin在一次按钮上为您构建的语句进行了尝试,但仍然相同. 由于更改名称不是一个选择,即使我知道这很糟糕,也没有其他选择,只能尝试让他找到该表.

Still the same error. I tried it with a ` around the table or with the statement phpmyadmin builds for you on one button push but still the same. Since changing the name is not an option, even though I know it's bad, there is no other option than trying to get him find that table.

我想念什么?

有关php和mySql的信息:

Information about php and mySql:

  • PHP版本:5.6.38
  • 数据库客户端版本:libmysql-mysqlnd 5.0.11
  • 服务器版本:10.1.36-MariaDB

编辑 我已经阅读了有关未正确安装mySQL的错误的信息,该错误发生的频率更高.由于我已经用XAMPP安装了整个软件包,所以不可能出现这个错误,不是吗?

EDIT I have read about a bug when mySQL haven't been installed correctly, this error occurs more often. Since I've installed the whole package with XAMPP, there could be no possibility of this bug, isn't it?

推荐答案

首先,请确保您有一个像这样命名的表:

First, make sure you have a table named like that:

select * from information_schema.tables where table_schema = 'MyDatabase' and table_name = 'user';


`user´是保留的关键字,因此您需要在表名前加上反引号.


`user´ is a reserved keyword, so you need to quote your table name with backticks.

UPDATE
    MyDatabase.`user`
SET
    MyDatabase.`user`.registeredAt = NOW()
WHERE
    MyDatabase.`user`.id = 3;

当您的数据库名称也需要引用时,请不要同时包含数据库名称和表名称.

When your database name also needs quoting, do not include both database name and table name.

这是错误的:

`databasename.tablename`

这是正确的:

`databasename`.`tablename`

这篇关于MySQL更新语句:“字段列表"中的未知“表"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆