天天看點

MySQL多個相同結構的表查詢并把結果合并放在一起的語句(union all)

union all

select * from table1001 where price > 10
union all
select * from table1002 where price > 10
union all
select * from table1003 where price > 10
order by ID      

列的個數要保持一緻,列名可以不一樣,但是對應的列的資料類型要一樣。同樣可以使用order by,limit這些。

參考:

http://bbs.51cto.com/thread-1076108-1-1.html

繼續閱讀