如题:
1.select  * from xptemp2010
  所影响的行数为 18130 行)
2.SELECT   xptemp2010.KCJHGL_KJND,
xptemp2010.KCJHGL_KJQJ,
xptemp2010.KCJHGL_CKBH,
xptemp2010.KCJHGL_WLBH,
lswlzd.lswlzd_wlmc,
lswlzd.lswlzd_ggxh,
lswlzd.lswlzd_lbbh,
tmrolldata.width,
xptemp2010.KCJHGL_JH,
xptemp2010.KCJHGL_HWBH,
xptemp2010.KCJHGL_SL,
xptemp2010.pdsl,
( xptemp2010.pdsl - xptemp2010.KCJHGL_SL ) as yksl,
czy,
czrq
FROM xptemp2010,lswlzd,tmrolldata
WHERE
( xptemp2010.KCJHGL_JH = tmrolldata.barcode_id) AND
( xptemp2010.kcjhgl_wlbh = tmrolldata.wlbh) and 
( xptemp2010.kcjhgl_wlbh = lswlzd.lswlzd_wlbh ) and 
( lswlzd.lswlzd_wlbh = tmrolldata.wlbh)
ORDER BY xptemp2010.pdsl
(所影响的行数为 18131 行)为什么2 比 1 多了一行?

解决方案 »

  1.   

    lswlzd,tmrolldata二张表中可能有重复的数据,你查一下看看,xptemp2010表的匹配就多了一条记录。
      

  2.   

    条件不一样,结果自然是不一样xptemp2010与另外两个表中关联的数据其中一个表中存在重复数据
      

  3.   

    declare @t table(id int)
    declare @a table(id int)
    insert @t select 1
    insert @a select 1 union all select 1select * from @t 
    select * from @t,@a
    id
    -----------
    1(1 行受影响)id          id
    ----------- -----------
    1           1
    1           1(2 行受影响)
      

  4.   


    --
    select * from tmrolldata  
    where barcode_id in (select barcode_id from tmrolldata group by barcode_id having(count(*))>1 )
    ( 所影响的行数为 2 行)
    果然是存在重复行。多谢二位。