SQL not in 两个表找不同的问题 100分在线等……现在有表t1,t2(结构相同)分别为t1:t2:a1 a2 a3 a1 a2 a301 张三 90 01 张三 9802 李四 85 04 谢六 8803 王五 89 05 陈四 87我现在想要找出t1.a1中的值在t2.a1中没有
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/19 12:13:44
![SQL not in 两个表找不同的问题 100分在线等……现在有表t1,t2(结构相同)分别为t1:t2:a1 a2 a3 a1 a2 a301 张三 90 01 张三 9802 李四 85 04 谢六 8803 王五 89 05 陈四 87我现在想要找出t1.a1中的值在t2.a1中没有](/uploads/image/z/7348356-36-6.jpg?t=SQL+not+in+%E4%B8%A4%E4%B8%AA%E8%A1%A8%E6%89%BE%E4%B8%8D%E5%90%8C%E7%9A%84%E9%97%AE%E9%A2%98+100%E5%88%86%E5%9C%A8%E7%BA%BF%E7%AD%89%E2%80%A6%E2%80%A6%E7%8E%B0%E5%9C%A8%E6%9C%89%E8%A1%A8t1%2Ct2%28%E7%BB%93%E6%9E%84%E7%9B%B8%E5%90%8C%29%E5%88%86%E5%88%AB%E4%B8%BAt1%3At2%3Aa1+a2+a3+a1+a2+a301+%E5%BC%A0%E4%B8%89+90+01+%E5%BC%A0%E4%B8%89+9802+%E6%9D%8E%E5%9B%9B+85+04+%E8%B0%A2%E5%85%AD+8803+%E7%8E%8B%E4%BA%94+89+05+%E9%99%88%E5%9B%9B+87%E6%88%91%E7%8E%B0%E5%9C%A8%E6%83%B3%E8%A6%81%E6%89%BE%E5%87%BAt1.a1%E4%B8%AD%E7%9A%84%E5%80%BC%E5%9C%A8t2.a1%E4%B8%AD%E6%B2%A1%E6%9C%89)
SQL not in 两个表找不同的问题 100分在线等……现在有表t1,t2(结构相同)分别为t1:t2:a1 a2 a3 a1 a2 a301 张三 90 01 张三 9802 李四 85 04 谢六 8803 王五 89 05 陈四 87我现在想要找出t1.a1中的值在t2.a1中没有
SQL not in 两个表找不同的问题 100分在线等……
现在有表t1,t2(结构相同)分别为
t1:t2:
a1 a2 a3 a1 a2 a3
01 张三 90 01 张三 98
02 李四 85 04 谢六 88
03 王五 89 05 陈四 87
我现在想要找出t1.a1中的值在t2.a1中没有的(仅a1列)
结果如下:
a1 a2 a3
02 李四 85
03 王五 89
我使用:
select * from t1 where a1 not in (select t1.a1 from t1,t2 where t1.a1=t2.a1)
查询结果,程序无响应……(估计记录集太多)
现在请高手写出sql语句来,或者纠正我的错误……
使用not exists不行,得出结果为空,select * from t1 where a1 not in (select a1 from t2)程序依旧无响应
SQL not in 两个表找不同的问题 100分在线等……现在有表t1,t2(结构相同)分别为t1:t2:a1 a2 a3 a1 a2 a301 张三 90 01 张三 9802 李四 85 04 谢六 8803 王五 89 05 陈四 87我现在想要找出t1.a1中的值在t2.a1中没有
select * from t1 where a1 not in (select a1 from t2)
或者
select * from t1 where not exists(select t2.a1 from t2 where t2.a1=t1.a1)
建议用not exists,比in快