主要目的是想将bd_psnbasdoc,bd_psndoc,hi_psndoc_deptchg这三张表的部分数据抽取出来形成展现在一块,但是我写了一段出来,同一个人的信息出现了很多重复的记录,求帮助!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.insource
from  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

解决方案 »

  1.   

    你要不重复的话直接在select后面加上distinct就没有重复的了
      

  2.   

    你直接在select后面加上distinct就行了,那样就没有重复的了
      

  3.   

    select distinct(xxx) from ***
      

  4.   

    我的需求就是,想要将bd_psnbasdoc,bd_psndoc,hi_psndoc_deptchg这三张表里抽取想要的字段及字段下的数据重新组合到另一个表里去,而要求这三个表组合起来的时候不出现大量的重复数据,存到的新表还暂未定义字段,这些字段就是靠那三个表进行组合的
      

  5.   


    select a.pk_psnbasdoc,a.psnname,a.pk_corp,b.pk_postdoc,
           b.pk_jobserial,b.pk_psncl,b.pk_dutyrank,c.groupdef1,
           c.groupdef6,c.groupdef3,c.groupdef2,c.groupdef4,
           bd_psnbasdoc.employform,  --bd_psnbasdoc未访问的表
           c.poststat,a.penelauth,b.begindate,c.insource
    from bd_psndoc c inner join hi_psndoc_deptchg b on c.pk_psncl=b.pk_psncl  
    inner join bd_psnbasdoc a on a.psnname=c.psnname
     LZ有发现 还一个表(bd_psnbasdoc)没确定关系么? 如何来连接这个表 确定应该就没重复了吧?  
      

  6.   

    sorry 眼都看花了 不过怎么整理好看点 select distinct a.pk_psnbasdoc,a.psnname,a.pk_corp,b.pk_postdoc,
           b.pk_jobserial,b.pk_psncl,b.pk_dutyrank,c.groupdef1,
           c.groupdef6,c.groupdef3,c.groupdef2,c.groupdef4,
           a.employform,c.poststat,a.penelauth,b.begindate,c.insource
    from bd_psndoc c inner join hi_psndoc_deptchg b on c.pk_psncl=b.pk_psncl  
    inner join bd_psnbasdoc a on a.psnname=c.psnname
    先发下表的关系吧 
      

  7.   

    bd_psnbasdoc人员基本信息,bd_psndoc工作信息,hi_psndoc_deptchg任职情况,bd_psndoc工作信息与hi_psndoc_deptchg任职情况通过人员类别pk_psncl进行关联,bd_psnbasdoc人员基本信息与bd_psndoc工作信息通过人员姓名psnname关联
      

  8.   


    select distinct a.pk_psnbasdoc,a.psnname,a.pk_corp,b.pk_postdoc,
           b.pk_jobserial,b.pk_psncl,b.pk_dutyrank,c.groupdef1,
           c.groupdef6,c.groupdef3,c.groupdef2,c.groupdef4,
           a.employform,c.poststat,a.penelauth,b.begindate,c.insource
    from bd_psndoc c,bd_psnbasdoc a,hi_psndoc_deptchg b
    where c.pk_psncl=b.pk_psncl and a.psnname=c.psnname
     重复字段是哪些   关系是不是唯一?