我有两个表中的Postgres:SQL更新基础上的所有字段加入型号
Sources [id, term, type]
Posts [id, source_id, message, term, type]
我去正火这个数据,所以我加入期限和类型的列到每个帖子,并摆脱Sources表。
有没有办法做一个FAST查询,更新帖子与他们各自的源数据(有大约800万个帖子)。
喜欢的东西:
UPDATE posts
JOIN sources
ON posts.source_id = sources.id
SET post.term = sources.term,
posts.term_type = sources.term_type;
但是,抛出一个语法错误我。
我想你错过了你改变'posts'结构的部分?因为你的'post'定义没有'term'或'term_type'字段。和'源'不存在于任何表 –
@JuanCarlosOropeza true!我已更新。 – goddamnyouryan
好我更新我的答案:) –