首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

高分求查询语句解决方法

2012-03-31 
高分求查询语句table1(aa,bb,cc),11,22,3301,02,0301,04,05table2(aa,bb,cc)10,22,3301,02,0402,04,05我想

高分求查询语句
table1(aa,bb,cc),
              11,22,33
              01,02,03
              01,04,05
table2(aa,bb,cc)
              10,22,33
              01,02,04
              02,04,05

我想得到的是把table1和table2中aa,bb列看着是一个组合列来查询

--比如我想得到vtable2中除掉第2行的数据。
也就是得到的就是下面这个语句相反的结果。
select   b.*   from   table1   a,table2   b   where   a.aa=b.aa   and   a.bb=b.bb


[解决办法]
select ta.* from table2 ta,
(
select b.* from table1 a,table2 b where a.aa=b.aa and a.bb=b.bb
) tb
where ta.aa <> tb.aa and ta.bb <> tb.bb

[解决办法]
於SQL Server 2005中求差集
SELECT * FROM Table2
EXCEPT
SELECT * FROM Table1

热点排行