SQL:表的一个字段复制到另一个表的字段中.

来源:百度知道 编辑:UC知道 时间:2024/06/08 00:56:23
如何将表user_info中的字段u_name中的姓名复制到表report_state中的字段user_name中?
在百度上找了一个,但是无法实现:update report_state set report_state.user_name=user_info.u_name from report_state,user_info

多多指教!!

update user_info a set a.u_name=(select b.user_name from report_state b where a.主键=b.主键)

俩表靠什么关联,你自己应该清楚吧,把两个主键的位置换成你表里的字段

或许你只是想把该列的数据全插入到另张表中而已。。两表并无关联?
你得说详细点,两表中还有些什么字段?

insert into report_state (user_name) select u_name from user_info

是不是缺少where 部分??
比如where report_state.id=user_info.id