这是我正在尝试的伪代码:
update msa_list_copy
select group_concat(distinct msa_name separator ', ') as concat_msa_name
group by msa
我的表msa_list_copy
有两列...... msa和msa_name。我正在尝试连接共享相同msa(数字)的msa_names,并将此值保存在(当前为空)第三列`concat_msa_name中,但我无法完全正确。
答案 0 :(得分:1)
您需要指定要更新的字段。
update msa_list_copy join
(select msa, group_concat(distinct msa_name separator ', ')
as concat_msa_name from msa_list_copy
group by msa) as t0 using(msa)
set msa_list_copy.concat_msa_name=t0.concat_msa_name
答案 1 :(得分:0)
SQL是:
update msa_list_copy inner join
(select group_concat(distinct msa_name separator ', ') as concat_msa_name
group by msa) as q on msa_list_copy.concat_msa_name=q.concat_msa_name set msa_list_copy.concat_msa_name = q.concat_msa_name