多表查询的问题。。
比如 现在有3个表  第一个表a字段1到10
                第二个表a字段11到20
                第三个表a字段21到30.
我想联合这三个表 条件a字段的3到28的b字段的内容    在一列显示出来   该怎么写

解决方案 »

  1.   

    select b from tb1 where a>=3
    union all
    select b from tb2
    union all
    select b from tb3 where a<=28
      

  2.   

    ???
    select b from
    (select a,b from [表一]
    union all
    select a,b from [表二]
    union all
    select a,b from [表三]
    )aa
    where a between 3 and 28
      

  3.   


    select a1 from tb1
    union all
    select a2 from tb1
    ...
    select a10 from tb1
    ...
      

  4.   


    select b from (select * from tb1 union all select * from tb2 union all select * from tb3) c where c.a>=3 and c.a<=28
      

  5.   

    select b from
    (select a,b from [表一]
    union all
    select a,b from [表二]
    union all
    select a,b from [表三]
    )aa
    where a between 3 and 28