本帖最后由 dxmbxh6 于 2014-06-13 14:14:55 编辑

解决方案 »

  1.   

    结果的type 字段在两个表里都没有,来自哪里?
      

  2.   


    select 'a' as tname , id, time , title from a 
    union all 
    select 'b' as tname , id , time  ,url from b 
    order by 2,1
      

  3.   

    沒看出什麼邏輯
    為甚麼a表的id=2 與b表的id=4 記錄要刪除?
      

  4.   

    如果一定要可以這樣寫
    (SELECT 'a' as type,id,time as date,title FROM `a` where id<>2) union all (select 'b' as type,id, time as date, url as title from `b` where id<>4) order by 2,1type id date title
    a 1 2014-05-01 aaaaaa
    b 1 2014-05-03 cccccc
    b 2 2014-05-04 dddddd
    b 3 2014-05-05 eeeeee