大家好,有两张表A,B 字段分别是 A{id,name} B{id,password} 现要把这两张表的数据合并到一表未建的新表C{id,name,password}, 请问大神问这要怎么实现啊。

解决方案 »

  1.   

    insert into c(id,name,password) as 
    (select a.id,a.name,b.password from A a,B b
    where a.id=b.id)
      

  2.   

    而且这语句也没见有新建表C啊,C表的ID是自动生成的
      

  3.   

    你C表的ID 是来自A表呢 还是来自B表呢?
    而且2张没有关系的表合起来 数据不会是随便凑在一起的吧。。
      

  4.   

    id自动生成估计是用了序列,建议lz最好把给出几个例子数据
      

  5.   

    lz在开玩笑吧? 2表没任何联系 怎么合成  还是说b一行数据对应a的一行数据?
      

  6.   

    select bd_psnbasdoc.pk_psnbasdoc,bd_psnbasdoc.psnname,bd_psnbasdoc.pk_corp,hi_psndoc_deptchg.pk_postdoc,hi_psndoc_deptchg.pk_jobserial,hi_psndoc_deptchg.pk_psncl,hi_psndoc_deptchg.pk_dutyrank,bd_psndoc.groupdef1,bd_psndoc.groupdef6,bd_psndoc.groupdef3,bd_psnbasdoc.employform,bd_psndoc.groupdef2,bd_psndoc.groupdef4,bd_psndoc.poststat,bd_psnbasdoc.penelauth,hi_psndoc_deptchg.begindate,bd_psndoc.insourcefrom  bd_psndoc inner join hi_psndoc_deptchg on bd_psndoc.pk_psncl=hi_psndoc_deptchg.pk_psncl inner join bd_psnbasdoc on bd_psnbasdoc.psnname=bd_psndoc.psnname 写完后会出现很多重复的记录,请高手解答
      

  7.   

    没关联。。你怎么 inner join。。