CentOS 4或5,使用MySQL 5.0.77:
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语句,所以我知道这不是拼写错误。这可能是什么问题?
谢谢!
答案 0 :(得分:6)
刻度线用于引用列和表名。使用引号中的点,它不会将其视为部件之间的分隔符。添加几个额外的刻度标记来纠正它。
UPDATE
`userTable`
INNER JOIN `anotherTable`
ON `userTable`.`userid`=`anotherTable`.`userid`
SET `userTable`.`someField`="Jimmy Page"
WHERE `userTable`.`someField`="Jim Morrison"
AND `anotherTable`.`date` < NOW();