由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 找不match的记录
相关主题
compare two large tables SQL (转载)Teradata 的大拿呢
SQL copy a table into a new table and add a new columnHow to Import a Datatable as fast as possible?
Re: [转载] what's the equivalent of 'minus' (oracle) in access?请问个join的问题
aks a simple SQL question菜鸟问.asp 里的select语句在基于SQL sever和Access语法上的不
2个table, 一个里面有4万个email, 一个里面有1万6千个email,如何比较?问个SQL问题
一个有关查询的语句常用SQL的误区???--新手请绕行
[转载] strong SQL skills?MySQL语句请教
怎样快速得到两个表的交集请教:如何优化,提取组间最大行
相关话题的讨论汇总
话题: t1话题: t2话题: c2话题: c1话题: 记录
进入Database版参与讨论
1 (共1页)
x*g
发帖数: 689
1
问一个新手问题,如何根据多个列找不match的记录?
Table T1, column C1, C2, C3
Table T2, column C1, C2, C4
用INNER JOIN可以找到T1里面满足条件
T1.C1=T2.C1 AND T1.C2=T2.C2的记录。
我的问题是如何选出在T1里面不满足
T1.C1=T2.C1 AND T1.C2=T2.C2的记录?
谢谢
c**t
发帖数: 2744
2
select C1, C2, C3 from T1
minus
select C1, C2, C3 from T2
vise versa

【在 x*g 的大作中提到】
: 问一个新手问题,如何根据多个列找不match的记录?
: Table T1, column C1, C2, C3
: Table T2, column C1, C2, C4
: 用INNER JOIN可以找到T1里面满足条件
: T1.C1=T2.C1 AND T1.C2=T2.C2的记录。
: 我的问题是如何选出在T1里面不满足
: T1.C1=T2.C1 AND T1.C2=T2.C2的记录?
: 谢谢

x*g
发帖数: 689
3
thanks for the reply.
I am using ms sql which I think doesn't have minus.
also the columns in T1 and T2 are not exact same.

【在 c**t 的大作中提到】
: select C1, C2, C3 from T1
: minus
: select C1, C2, C3 from T2
: vise versa

k***e
发帖数: 7933
4
ms sql 2005 has 'except'

【在 x*g 的大作中提到】
: thanks for the reply.
: I am using ms sql which I think doesn't have minus.
: also the columns in T1 and T2 are not exact same.

I*****y
发帖数: 602
5
Left join应该可以。
select T1.* from T1
left join T2 on T1.c1=T2.c1 and ...
where T2.C1 is null

【在 x*g 的大作中提到】
: 问一个新手问题,如何根据多个列找不match的记录?
: Table T1, column C1, C2, C3
: Table T2, column C1, C2, C4
: 用INNER JOIN可以找到T1里面满足条件
: T1.C1=T2.C1 AND T1.C2=T2.C2的记录。
: 我的问题是如何选出在T1里面不满足
: T1.C1=T2.C1 AND T1.C2=T2.C2的记录?
: 谢谢

J*******n
发帖数: 2901
6

同楼上
不过应该
where T2.C4 is null吧

【在 x*g 的大作中提到】
: 问一个新手问题,如何根据多个列找不match的记录?
: Table T1, column C1, C2, C3
: Table T2, column C1, C2, C4
: 用INNER JOIN可以找到T1里面满足条件
: T1.C1=T2.C1 AND T1.C2=T2.C2的记录。
: 我的问题是如何选出在T1里面不满足
: T1.C1=T2.C1 AND T1.C2=T2.C2的记录?
: 谢谢

1 (共1页)
进入Database版参与讨论
相关主题
请教:如何优化,提取组间最大行2个table, 一个里面有4万个email, 一个里面有1万6千个email,如何比较?
Urgent SQL problem!一个有关查询的语句
这个问题的sql query为什么这样写?[转载] strong SQL skills?
奇怪的 SQL 问题怎样快速得到两个表的交集
compare two large tables SQL (转载)Teradata 的大拿呢
SQL copy a table into a new table and add a new columnHow to Import a Datatable as fast as possible?
Re: [转载] what's the equivalent of 'minus' (oracle) in access?请问个join的问题
aks a simple SQL question菜鸟问.asp 里的select语句在基于SQL sever和Access语法上的不
相关话题的讨论汇总
话题: t1话题: t2话题: c2话题: c1话题: 记录