sql union 的用法

分为union与union all
union 缺省在合并结果集后消除重复项,
union all 指定在合并结果集后保留重复项, 
打个比喻吧 比如A表的数据是 A{ 1,4,5,9}       B{2,3,4,5}
那我执行此语句 select * from A union select * from B 那结果是{1,2,3,4,5,9}
如果执行select * from A union all select * from B 结果是{1,2,3,4,4,5,5,9}
posted @ 2012-05-24 17:58  呓语  阅读(251)  评论(0编辑  收藏  举报
welcome to this garden! --Chenly