如何用insert 或update实现

来源:百度知道 编辑:UC知道 时间:2024/06/04 07:35:11
想要实现将a表全字段的部分数据复制给b表,用insert 或update如何实现?
insert into xj_err * sellect * from xj where error is not null;
update xj_err set * sellect * from xj where error is not null;
这两句为什么执行不了?
update xj_err set xj_err.* in (select * from xj where error is not null);
此句实现不了!

使用select插入其他表的时候 select出来的字段应该和被插入表的字段完全匹配才可以

update也一样

insert into xj_err select * from xj where error is not null;

update xj_err set xj_err.* in (select * from xj where error is not null);

.....

假若a表中只有sid,sname,sage 这三个字段,写法如下,要把实际的字段查询出来再插进去。这种方法叫“批插入”
insert into table_b(sid,sname,sage) select sid,sname,sage from table_a

不要用*号.直接写出字段名字.
insert into xj_err(l1,l2,l3...) select l1,l2,l3... from xj where error is not null

得用游标