萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> mysql UNION 語法詳細說明與實例教程

mysql UNION 語法詳細說明與實例教程

mysql教程 union 語法詳細說明與實例教程

本文介紹如何在mysql中使用union來組合成一個單一的結果

union語法

select field1, field2 ...union [all | distinct]select field1, field2 ...

下面看一款查詢三個表普通方法

select brand from car;
select brand from computer;
select brand from clothing;

我們利用union連接起來查詢


select brand from car union select brand from computer union select brand from clothing;

select brand from car union all select brand from computer union allselect brand from clothing;

 

copyright © 萬盛學電腦網 all rights reserved