select a.id,
       b.name,
       Nid=(case when a.FNType=0 then (select b1.name from table2 b1 where b1.id=a.Nid) when a.FNType=1 then (select c1.name from table3 c1 where c1.id=a.Nid) End),
       a.FNType,
       Pid=c.name,
       Nxid=c.name
from   table1 a,table2 b,table3 c
where  a.Fid=b.id
       and c.id=a.pid结果
id     name       Nid        FNType      Pid            Nxid                 
---------------------------------------- ---------------------------------- 
1      设计       设计        0           2D设计         2D设计
2      工艺       铜公工艺    1           铜公工艺        铜公工艺(所影响的行数为 2 行)              

解决方案 »

  1.   

    列名有个忘记改了.呵呵select a.id,
           Fid=b.name,
           Nid=(case when a.FNType=0 then (select b1.name from table2 b1 where b1.id=a.Nid) when a.FNType=1 then (select c1.name from table3 c1 where c1.id=a.Nid) End),
           a.FNType,
           Pid=c.name,
           Nxid=c.name
    from   table1 a,table2 b,table3 c
    where  a.Fid=b.id
           and c.id=a.pid
      

  2.   

    select ID, Fid= (select Name from table2 where id=a.Fid),  Nid = (select (case when a.fntype=0 then table2.name else table3.name end) from table2,table3 where a.nid=table2.id and a.nid=table3.id ),     FNType,    Pid = (select name from table3 where id=a.pid),     Nxid  =( select name from table3 where id=a.nxid )
    from table1 a