mysql 更新错误 1054:'field list' 中的未知列 'x'
mysql update ERROR 1054 : Unknown column 'x' in 'field list'
我正在尝试更新 mysql table 并收到错误 1054,之后发生了一些奇怪的事情。
Table 架构
CREATE TABLE `useraccount` (
`userId` bigint(20) NOT NULL,
`currentBalance` float NOT NULL,
`currentDataBalance` bigint(20) NOT NULL,
PRIMARY KEY (`userId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
我的 table 中有一个条目,即
mysql> select * from UserAccount;
+--------+----------------+--------------------+
| userId | currentBalance | currentDataBalance |
+--------+----------------+--------------------+
| 1 | 0 | 4296 |
+--------+----------------+--------------------+
我尝试更新 currentDataBalance
字段并收到错误
ERROR 1054 (42S22): Unknown column '253600l' in 'field list'
mysql> update UserAccount set currentDataBalance=253600l where userId=1;
ERROR 1054 (42S22): Unknown column '253600l' in 'field list'
然后我删除了更新值的最后一位 (从 253600l 到 253600) 并且值得到了更新
mysql> update UserAccount set currentDataBalance=253600 where userId=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
然后我再次将值更改为之前的值(从 253600 到 2536001),这次值更新了。
mysql> update UserAccount set currentDataBalance=2536001 where userId=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
我在 Whosebug 上浏览了很多与错误 1054 相关的帖子,但没有得到相关答案。
您的更新查询中有小的拉丁字符 "L" 而不是数字“1”。由于您要设置的值看起来像 MySQL 的标识符,它会尝试查找具有此类名称的列,但找不到它,这就是您收到此错误的原因。
这个查询
update UserAccount set currentDataBalance=253600l where userId=1;
returns 这个错误:
ERROR 1054 (42S22): Unknown column '253600l' in 'field list'
因为你的 "number" 中有一个字母:253600l,这会将你的数字变成 string.Since 这个字符串没有用引号引起来, MySQL 假定它是数据库中对象的名称,在本例中是一列。
该对象不存在,因此出现此特定错误。
我正在尝试更新 mysql table 并收到错误 1054,之后发生了一些奇怪的事情。
Table 架构
CREATE TABLE `useraccount` (
`userId` bigint(20) NOT NULL,
`currentBalance` float NOT NULL,
`currentDataBalance` bigint(20) NOT NULL,
PRIMARY KEY (`userId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
我的 table 中有一个条目,即
mysql> select * from UserAccount;
+--------+----------------+--------------------+
| userId | currentBalance | currentDataBalance |
+--------+----------------+--------------------+
| 1 | 0 | 4296 |
+--------+----------------+--------------------+
我尝试更新 currentDataBalance
字段并收到错误
ERROR 1054 (42S22): Unknown column '253600l' in 'field list'
mysql> update UserAccount set currentDataBalance=253600l where userId=1;
ERROR 1054 (42S22): Unknown column '253600l' in 'field list'
然后我删除了更新值的最后一位 (从 253600l 到 253600) 并且值得到了更新
mysql> update UserAccount set currentDataBalance=253600 where userId=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
然后我再次将值更改为之前的值(从 253600 到 2536001),这次值更新了。
mysql> update UserAccount set currentDataBalance=2536001 where userId=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
我在 Whosebug 上浏览了很多与错误 1054 相关的帖子,但没有得到相关答案。
您的更新查询中有小的拉丁字符 "L" 而不是数字“1”。由于您要设置的值看起来像 MySQL 的标识符,它会尝试查找具有此类名称的列,但找不到它,这就是您收到此错误的原因。
这个查询
update UserAccount set currentDataBalance=253600l where userId=1;
returns 这个错误:
ERROR 1054 (42S22): Unknown column '253600l' in 'field list'
因为你的 "number" 中有一个字母:253600l,这会将你的数字变成 string.Since 这个字符串没有用引号引起来, MySQL 假定它是数据库中对象的名称,在本例中是一列。 该对象不存在,因此出现此特定错误。