--例如:
select t1.* , t2.*,
case when charindex('某内容' , 某字段) > 0 then t1.某字段 else t2.某字段 end
from t1 , t2 where t1.id = t2.id

解决方案 »

  1.   

    SELECT ISNULL(NULLIF(t1.lie,'a'),t2.另一列) FROM t1
    INNER JOIN t2
    ON ..
      

  2.   

    else 可以直接显示内容不?因为t1,t2没关联
      

  3.   

    要直接显示另一个内容改成下面的出现问题,指点下  (case 和 from 间的语句 出错 )SELECT A.NewDispatchCode, A.Title, A.NiGaoPeople, CONVERT(char(10), A.OverData, 121) 
          AS OverData1, A.FaWenType, CASE WHEN charindex('中电工程装备', A.H_Key_Code) 
          > 0 THEN A.H_Key_Code, ELSE ('漳电检') 
    FROM New_Dispatch_Paper A INNER JOIN
          New_Dispatch_GuiDang B ON A.NewDispatchCode = B.NewDispatchCode
    WHERE (CONVERT(char(4), A.OverData, 121) = '2008')
    ORDER BY A.Hao
      

  4.   


    select t1.* , t2.*,
    case when charindex('note' , field) > 0 then t1.field else t2.field end
    from t1 , t2 where t1.id = t2.id