将sql查询的结果,插入到B表中,因为数据量比较大,所以插入时只想插入B表中没有的数据,怎么写?insert b select * from a where not exists(select 1 from b where id=a.id)
这条sql语句可以实现 将a表中的数据不重复的插入到b表我的问题是我数据库中a表是不存在的,他是从其它几个表关联后得到的数据,所以我在项目里(.net项目)用DataTable ds = new DataTable("aa");
        da.Fill(ds); 给表起了名字,然后用上边的sql语句,但是不对还有数据是插入到sqlite数据库中,是不是因为sqlite的语法与sql不同的原因?

解决方案 »

  1.   

    有一个行为叫insert into,有一种选择叫DISTINCT。
      

  2.   

    select a.* into #tb from a left join b on a.id=b.id
     where b.id is null
    insert b select * from #tb
      

  3.   

    我是要将sqlserver中查询出来的数据(有多条,数量有时非常大),插入到sqlite中,这样sql语句没法关联啊
      

  4.   

    我的是从sql2005中查询出来的数据,要更新插入到sqlite中
      

  5.   


    select distinct * from 表