2019-03-10
閱讀量:
769
mysql常見的面試題(四)
union 與union all的區(qū)別
union 在進(jìn)行表鏈接后會篩選掉重復(fù)的記錄,所以在表鏈接后會對所產(chǎn)生的結(jié)果集進(jìn)行排 序運(yùn)算,刪除重復(fù)的記錄再返回結(jié)果。 union all 則會顯示重復(fù)結(jié)果,只是簡單的兩個結(jié)果合并并返回.所以效率比union高,在保證沒有重復(fù)數(shù)據(jù)的情況下用union all.
select name from table1
union
select name ?from table2;






評論(0)


暫無數(shù)據(jù)
推薦帖子
0條評論
1條評論
0條評論
0條評論