大神 @唐诗三百首  @DBA_Huangzj  求帮忙 

解决方案 »

  1.   

    你还少了一个判断哦,就是判断house是否存在或者说包含housetemp的内容哦
    这个是重点 
      

  2.   

    那第二个问题呢? 就是第二条数据没处理 麻烦下了加上Isnull 数据都没变化,没处理到更新
    UPDATE house
     SET house.HouseType = a.HouseType, 
           house.DataType = a.DataType, 
           house.ProjectName  = a.ProjectName ,
           house.Area = a.Area
    FROM  (
    select h.Phone,
      ISNULL(ht.HouseType,case when charindex(ht.HouseType, h.HouseType)=0 then h.HouseType+','+ht.HouseType 
                else h.HouseType end) HouseType,
     ISNULL(ht.DataType, case when charindex(ht.DataType, h.DataType)=0 then h.DataType+','+ht.DataType 
                else h.DataType end) DataType,
      ISNULL(ht.ProjectName,case when charindex(ht.ProjectName , h.ProjectName )=0 then h.ProjectName +','+ht.ProjectName  
                else h.ProjectName  end) ProjectName,
     ISNULL(ht.Area, case when charindex(ht.Area, h.Area)=0 then h.Area+','+ht.Area 
                else h.Area end) Area
    from House h
    inner join HouseTemp ht on h.Phone = ht.Phone 
    ) a INNER JOIN
           house b ON a.Phone = b.Phone
      

  3.   

    接上一个帖子 求sql 急用 阅读次数:242次;回复次数:22次