UPDATE tb_grjbxx A SET 字段名=(select dwid00 fromzh_tbryda B where A.xgrid0=B.id0000);
注意要确保select dwid00 fromzh_tbryda B where A.xgrid0=B.id0000返回的记录条数<=1
insert into tb_grjbxx(column_name ) select dwid00 from tb_grjbxx,zh_tbryda where xgrid0=id0000 ;
没有看懂你写的sql语句是什么意思。按照你的中文描述,我写了一个sql语句,看看对你是否有用。 INSERT INTO tb_grjbxx(字段名) SELECT dwid00 FROM tb_grjbxx t WHERE exist ( SELECT 1 FROM zh_tbryda d WHERE t.dwid00=d.dwid00 )
select dwid00 from tb_grjbxx,zh_tbryda where xgrid0=id0000 这个产生了笛卡尔积 照楼主的意思应该是 insert into tb_grjbxx(field_name) select dwid00 from tb_grjbxx a,zh_tbryda b where a.dwid00 = b.dwid00 and b.xgrid0='id0000' 或者 insert into tb_grjbxx(field_name) select dwid00 from tb_grjbxx a where exists( select 1 from zh_tbryda b where a.dwid00 = b.dwid00 and b.xgrid0='id0000' )
insert into tb_grjbxx(field_name) select dwid00 from tb_grjbxx a,zh_tbryda b where a.dwid00 = b.dwid00 and b.xgrid0='id0000'
select dwid00 from tb_grjbxx,zh_tbryda where xgrid0=id0000
;
INSERT INTO tb_grjbxx(字段名)
SELECT dwid00 FROM tb_grjbxx t
WHERE exist (
SELECT 1 FROM zh_tbryda d
WHERE t.dwid00=d.dwid00
)
照楼主的意思应该是
insert into tb_grjbxx(field_name)
select dwid00
from tb_grjbxx a,zh_tbryda b
where a.dwid00 = b.dwid00
and b.xgrid0='id0000'
或者
insert into tb_grjbxx(field_name)
select dwid00
from tb_grjbxx a
where exists(
select 1 from zh_tbryda b
where a.dwid00 = b.dwid00
and b.xgrid0='id0000'
)
select dwid00
from tb_grjbxx a,zh_tbryda b
where a.dwid00 = b.dwid00
and b.xgrid0='id0000'