SQL语句中,union并集,intersect交集,except差集
摘要:注意此语法仅在SQL Server 2005及以上版本支持。要求:表t1,t2的结构一致t1中的数据:1,2,3,4,5t2中的数据:3,4,5,6,7UNION是指合并第一个集合,第二个集合中的数据。select*fromt1UNONselect*fromt2结果:1,2,3,4,5,6,7 UNION有重复记录只取一条,用UNIONALL时取所有重复记录select*fromt1UNONALLselect*fromt2结果:1,2,3,4,5,3,4,5,6,7INTERSECT是指在两个集合中都存在的数据。select*fromt1INTERSECTselect*fromt2结果:3,.
阅读全文
posted @ 2013-03-01 12:30
浙公网安备 33010602011771号