SQL组合查询union
生活随笔
收集整理的這篇文章主要介紹了
SQL组合查询union
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
對一個表執行多個查詢,按一個查詢返回數據:
select 屬性集合0 form 表0 where 邏輯組合0
union
select 屬性集合0form 表0 where 邏輯組合1 等價于 select distinct 屬性集合0 form 表0 where 邏輯組合0 or 邏輯組合1
union:返回的是一個集合,不能含有相同的值
可以看出某些方面where與union之間可以相互轉換
屬性集合0與屬性集合0`中列的類型不一定需要都相同(DBMS有一定的類型轉換功能)
select 屬性集合0 form 表0 where 邏輯組合0
union
select 屬性集合0form 表0 where 邏輯組合1 等價于 select 屬性集合0 form 表0 where 邏輯組合0 or 邏輯組合1
union all:返回的結果,可以有相同的值
總結
以上是生活随笔為你收集整理的SQL组合查询union的全部內容,希望文章能夠幫你解決所遇到的問題。