有两个表:
t1 t2 
通过表t3建立关联
t3有spbh和spid字段t1里有2677条记录
select a.spcd,a.spbh,a.spmc,b.zhjj into t4
from t1 a,t2 b
where a.spbh in(select spbh from t3 where spid=b.spid)写入t4后为什么记录只有2524了啊?

解决方案 »

  1.   

    写法好像没问题select a.spcd,a.spbh,a.spmc,b.zhjj into t4
    from t1 a,t2 b,t3 c
    where a.spbh=c.spbh and c.spid=b.spid
      

  2.   

    应该T1表中并不是所有的数据都能通过T3与T2关联
      

  3.   

    求助:在sybase中全外连接的写法!!
      

  4.   

    same question 
    HTTP://www.ebigear.com/Fund/PlayNews.php?NewsID=29453&ID=285885
      

  5.   

    select a.spcd,a.spbh,a.spmc,b.zhjj into t4
    from t1 a,t2 b
    where a.spbh in(select spbh from t3 where spid=b.spid)
    ---------------------------------------------------------如果(select spbh from t3 where spid=b.spid)显示出的 spbh 数并非是所有T1中的spbh 话,结果当然会是如此
      

  6.   

    可不可以这样来写:
    select a.spcd,a.spbh,a.spmc,b.zhjj into t4
    from t1 a,(Select A1.spbh,B1.Zhjj From T2 B1,T3 A1 WHere A1.spid=B1.spid) B
    WHere a.spbn=b.spbn如果结果还是一样的话,可以单独执行
    Select A1.spbh,B1.Zhjj From T2 B1,T3 A1 WHere A1.spid=B1.spid
    看下会有多少行记录
      

  7.   

    在逻辑处理上有问题,让人非常费解。
    select a.spcd,a.spbh,a.spmc,b.zhjj into t4
    from t1 a,t2 b
    where a.spbh in(select spbh from t3 where spid=b.spid)要是以t1为标准,那样可以考虑使用LEFT OUTER 语句
    SELECT a.spcd,a.spbh,a.spmc,b.zhjj INTO t4
    FROM t1 AS a  LEFT OUTER JOIN t2 AS b
    ON a.spbh=b.spbh AND a.spid=b.spid
      

  8.   

    --try
    select a.spcd,a.spbh,a.spmc,b.zhjj into t4
    from t1 a,t2 b,t3 c
    where a.spbh=c.spbh and b.spid=c.spid
      

  9.   

    如果(select spbh from t3 where spid=b.spid)显示出的 spbh ,如果全部事T1中的spbh ,结果就会正确,否则就不对
      

  10.   

    发现一个问题:
    表t1是从excel导入的
    excel中所有spbh都不为空
    但导入SQL Server里有144个spbh为空
    这是什么原因啊?