使用MySQL 5.0.77的CentOS 4或5:
mysql> UPDATE
-> `userTable`
-> INNER JOIN `anotherTable`
-> ON `userTable.userid`=`anotherTable.userid`
-> SET `userTable.someField`="Jimmy Page"
-> WHERE `userTable.someField`="Jim Morrison"
-> AND `anotherTable.date` < NOW();
ERROR 1054 (42S22): Unknown column 'userTable.someField' in 'field list'
mysql>
mysql> SELECT count(someField) FROM userTable;
+---------------+
| count(someField) |
+---------------+
| 5076 |
+---------------+
1 row in set (0.00 sec)
mysql>
我确实在终端中通过鼠标复制/粘贴将someField和userTable输入到SELECT语句中,所以我知道这不是拼写问题。这可能是什么问题?
谢谢!
最佳答案
刻度线用于引用列和表名。引号中带有圆点,因此不能将其视为零件之间的分隔线。添加几个额外的刻度线来更正它。
UPDATE
`userTable`
INNER JOIN `anotherTable`
ON `userTable`.`userid`=`anotherTable`.`userid`
SET `userTable`.`someField`="Jimmy Page"
WHERE `userTable`.`someField`="Jim Morrison"
AND `anotherTable`.`date` < NOW();
关于mysql - MySQL坚持认为该字段不存在,然后告诉我该字段确实存在,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7367553/