跨数据库更新?

时间:2011-03-08 16:40:21

标签: mysql

是否有可能 update proj_oct.writings set proj_oct.writings.writer_id=jozad_bkb.elx_content.writer where proj_oct.writings.id=jozad_bkb.elx_content.id ??

它给了我Unknown column 'jozad_bkb.elx_content.id' in 'where clause'但它存在。

谢谢。

修改:

将表复制到同一个数据库,这会失败:
 UPDATE writings SET writer_id = elx_content.writer WHERE id = elx_content.id

2 个答案:

答案 0 :(得分:2)

将其更改为更新/选择:

UPDATE writings SET writer_id = select writer from elx_content WHERE writings.id = elx_content.id

答案 1 :(得分:2)

找到解决方案:

update `elx_content` as x , writings as y set y.writer_id =x.writer  where y.id=x.id