表名:t1  t2  t3
相关字段:id  logo   date
要求:搜索所有logo = '1' 的记录,按照t1,t2,t3的顺序检索三个表,查询出id和date字段

解决方案 »

  1.   

    select id , logo , date , px = 1 from t1 where logo = '1'
    union all
    select id , logo , date , px = 2 from t2 where logo = '1'
    union all
    select id , logo , date , px = 3 from t3 where logo = '1'
    order by id , logo , date , px
      

  2.   

    select id,logo,date from t1 where logo='1'
    union all
    select id,logo,date from t2 where logo='1'
    union all
    select id,logo,date from t3 where logo='1'
      

  3.   

    select * from 
    (
        select id ,date from t1 where logo = '1'
        union all 
        select id ,date from t2 where logo = '1'
        union all
        select id ,date from t3 where logo = '1'
    ) t order by id 
      

  4.   

    select id,logo,date from t1 where logo='1'
    union all
    select id,logo,date from t2 where logo='1'
    union all
    select id,logo,date from t3 where logo='1'