查寻两表三字段都相等select A.* 
from test.dbo.外表 A
  left join test.dbo.内表 B 
     on (A.编码=B.编码 and A.通用名 = B.通用名 and A.质量层次=B.质量层次)外表共782条记录  
内表共749条记录  结果查出来782条记录,比内表还多,哪错了啊?

解决方案 »

  1.   

    没错如果要内表
    select A.* 
    from test.dbo.外表 A
    right join test.dbo.内表 B 
    on (A.编码=B.编码 and A.通用名 = B.通用名 and A.质量层次=B.质量层次)
      

  2.   

    select A.* 
    from test.dbo.外表 A
    inner join test.dbo.内表 B 
    on (A.编码=B.编码 and A.通用名 = B.通用名 and A.质量层次=B.质量层次)
      

  3.   

    left join多很正常啊 
    改成JOIN就行了
      

  4.   

    以内表为住表LEFT JOIN 
      

  5.   

    select A.* 
    from test.dbo.外表 A
    INNER join test.dbo.内表 B 
    on (A.编码=B.编码 and A.通用名 = B.通用名 and A.质量层次=B.质量层次)
      

  6.   

    inner jion 778条 还是比内表多
      

  7.   

    inner jion 778条 还是比内表多
      

  8.   

    查询外表数据是否有重复的。
    select 编码, 通用名, 质量层次,count(*) from 外表 A
    group by 编码, 通用名, 质量层次
    having count(*)>1