1、在sql server功能完全一样,但是很多数据库不支持
insert table1 
select * from a
所以,这样写的移植性差一点2、insert 和 where 一起用?
那只有insert into table1 
select * from a
where ...
这种格式吧?有什么要注意的?只能说按照要求写where子句了

解决方案 »

  1.   

    insert [into] tablename[(collists)] select-query  --列要相同,where子句当然可以在查询中
      

  2.   

    insert into table1 (b)
    select b from a
    where b<>a.b
    --------怎么能否把table1中没有的b从 a 中加入
      

  3.   

    insert into table1 (b)
    select b from a
    where not exists (
    select 1 from table1 
    where b=a.b
    )
      

  4.   

    不起作用?你这么写当然不起作用了,你的where b<>a.b,b和a.b都是a.b,唯一的作用是排除了null的数据not exists 效率还可以,如果效率还是不能接受的话,只能用临时表了
      

  5.   

    用临时表不是好方法,你先在a和table1 表的b字段加索引看看