insert 语句问题?
use my_oa
go
insert into tb_AA (InfoId)
select InfoId
from tb_BB
where tb_AA.AName = tb_BB .BName
插入表tb_AA时失败,错在哪里?该如何改呢?
------解决方案--------------------insert into tb_AA (InfoId) values(你的值)
------解决方案--------------------接分
------解决方案--------------------insert into tb_AA (A.InfoId)
select B.InfoId
from tb_BB B Left Join tb_AA A
On A.AName = B.BName
------解决方案--------------------use my_oa
go
insert into tb_AA (InfoId)
select tb_AA.InfoId
from tb_BB,tb_AA
where tb_AA.AName = tb_BB.BName
这样就可以了
------解决方案--------------------insert into tb_AA s(InfoId)
select InfoId
from tb_AA ,tb_BB
where tb_AA.AName = tb_BB .BName
------解决方案--------------------insert into tb_AA (A.InfoId)
select B.InfoId
from tb_BB B Left Join tb_AA A
On A.AName = B.BName
--------------------
正解
------解决方案--------------------insert into tb_AA (A.InfoId)
(select B.InfoId
from tb_BB B Left Join tb_AA A
On A.AName = B.BName)
------解决方案--------------------update 原理是一样的,可以用下面的语句
Update tb_AA set InfoId = B.InfoId
from tb_BB B Left Join tb_AA A
On A.AName = B.BName