select 'a' as tname , id, time , title from a union all select 'b' as tname , id , time ,url from b order by 2,1
沒看出什麼邏輯 為甚麼a表的id=2 與b表的id=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
select 'a' as tname , id, time , title from a
union all
select 'b' as tname , id , time ,url from b
order by 2,1
為甚麼a表的id=2 與b表的id=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