SQL 根据表1和表2 找出表1的数值不包括表2的数值 表1A列 B列1 101 201 302 302 202 10表2A列 B列1 102 302 10根据表1和表2 找出表1的数值不包括表2的数值结果A列 B列1 201 302 20 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select tb1.* from tb1 where not exists (select 1 from tb2 where tb2.a = tb1.a and tb2.b = tb1.b) create table tb1(A int, B int)insert into tb1 values(1 , 10 )insert into tb1 values(1 , 20 )insert into tb1 values(1 , 30 )insert into tb1 values(2 , 30 )insert into tb1 values(2 , 20 )insert into tb1 values(2 , 10 )create table tb2(A int, B int)insert into tb2 values(1 , 10 )insert into tb2 values(2 , 30 )insert into tb2 values(2 , 10 )select tb1.* from tb1 where not exists (select 1 from tb2 where tb2.a = tb1.a and tb2.b = tb1.b)drop table tb1 , tb2/*A B ----------- ----------- 1 201 302 20(所影响的行数为 3 行)*/ select 表1.* from 表1,表2where 表1.A列 <>表2.A列 and 表1.B列<>表2.B列 请教一个比较复杂的统计求和语句 能否动态命名列别名? [help]根据条件更新表中的数据 请教:如何将特殊格式的文本文件导入到数据表呢? 求一个多表查询的简单方法.... 我得ODBC不能设置SQL server ....请问是什么原因...waiting. 怎样能取出一个text字段的前十位字符? 如何把sql7.0中的数据导到sql2000中 SQLSERVER中nvarchar和varchar类型的区别是什么? 怎样提高SQLServer 2000中数据库连接的效率? 关于left join的问题,小菜鸟请教各位了 如何剔除掉在之前月份曾经出现过的记录的SQL语句
insert into tb1 values(1 , 10 )
insert into tb1 values(1 , 20 )
insert into tb1 values(1 , 30 )
insert into tb1 values(2 , 30 )
insert into tb1 values(2 , 20 )
insert into tb1 values(2 , 10 )
create table tb2(A int, B int)
insert into tb2 values(1 , 10 )
insert into tb2 values(2 , 30 )
insert into tb2 values(2 , 10 )select tb1.* from tb1 where not exists (select 1 from tb2 where tb2.a = tb1.a and tb2.b = tb1.b)drop table tb1 , tb2/*
A B
----------- -----------
1 20
1 30
2 20(所影响的行数为 3 行)
*/
where 表1.A列 <>表2.A列
and 表1.B列<>表2.B列