select treeid,Nodetext from tree  inner join Node1 on tree.NodeID =Node1.ID where tree.NodeTB='Node1'
union all
select treeid,Nodetext from tree  inner join Node2 on tree.NodeID =Node2.ID where tree.NodeTB='Node2'
这样可以了。

解决方案 »

  1.   

    select col1,col2=(case when a.col2='机构表' then (select 机构名称 from 机构表 where id=a.对应id) else (select 人员名称 from 人员表 where id=a.对应id) end) from 表3
    --未调试
      

  2.   

    select col1,col2=(case when a.col2='机构表' then (select 机构名称 from 机构表 where id=a.对应id) else (select 人员名称 from 人员表 where id=a.对应id) end) from 表3 a   --差了一个别名
      

  3.   

    --查询处理
    select 表3字段,case 对应表名 
    when '机构表' then (select 机构名称 from 机构表 where a.对应ID=id)
    when '人员表' then (select 人员名称 from 人员表 where a.对应ID=id)
    end
    from 辅助表 a
      

  4.   

    --测试--测试数据
    create table 机构表(ID int,机构名称 varchar(10))
    insert 机构表 select 1,'机构1'
    union  all   select 2,'机构2'
    union  all   select 3,'机构3'create table 人员表(ID int,人员名称 varchar(10))
    insert 人员表 select 1,'人员1'
    union  all   select 2,'人员2'
    union  all   select 3,'人员3'create table 辅助表(表3字段 varchar(10),对应ID int,对应表名 varchar(10))
    insert 辅助表 select '随便1',1,'机构表'
    union  all   select '随便2',2,'机构表'
    union  all   select '随便3',1,'人员表'
    union  all   select '随便4',2,'人员表'
    go--查询处理
    select 表3字段,case 对应表名 
    when '机构表' then (select 机构名称 from 机构表 where a.对应ID=id)
    when '人员表' then (select 人员名称 from 人员表 where a.对应ID=id)
    end
    from 辅助表 ago--删除测试
    drop table 机构表,人员表,辅助表/*--测试结果
    表3字段                  
    ---------- ---------- 
    随便1        机构1
    随便2        机构2
    随便3        人员1
    随便4        人员2(所影响的行数为 4 行)
    --*/
      

  5.   

    zjcxc(: 邹建 :) 
    人热心,水平也高,真的令我感动啊!