关于sql的insert select的写法有个问题

[复制链接]
查看11 | 回复4 | 2012-1-19 10:07:12 | 显示全部楼层 |阅读模式
第一种写法:insert into table2 select * from table1 where not exists(select * from from table2 where table2.key1=table1.key1 and table2.key2=table1.key2)第二种写法(效率会高一些)insert into table2 select table1.* from table1
left outer jion table2 ontable2.key1=table1.key1 and table2.key2=table1.key2
where...
回复

使用道具 举报

千问 | 2012-1-19 10:07:12 | 显示全部楼层
insert into table2 select * from table1 where key not in (select key from table2)--试试。...
回复

使用道具 举报

千问 | 2012-1-19 10:07:12 | 显示全部楼层
1、先创建一个临时表,字段类型与table2一致2、从table1中抽出数据按table2字段类型和要求整理一下数据插入到临时表3、再从临时表插入table2 还有一种可能table2表内是不是本身就有问题或其他表主键外键冲突?...
回复

使用道具 举报

千问 | 2012-1-19 10:07:12 | 显示全部楼层
ss...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行