这个SQL语句哪里有错

来源:百度知道 编辑:UC知道 时间:2024/06/08 01:14:56
update om_emporg2 t
set (t.orgid,t.empid)=(SELECT b.orgid,b.empid FROM om_employee b)
where exists (select 1 from om_employee)

其中表om_emporg2中有两个字段,orgid,empid都为空,我想把om_employee里面的字段复制到om_emporg表中,我执行这个语句能成功,但提示0条记录被更新,why

晕~~~
update 是用来更新你om_emporg2 表中存在的数据
你orgid,empid都为空 明显是个空表
那你就要用到insert 插入数据

insert into om_emporg2 (orgid,empid)
SELECT orgid,empid FROM om_employee

估计子查询返回的值多于一个吧...