简单sql问题,高分求解 select table1.* from table1, table2 where table1.e<>table2.a and table1.f<>table2.b 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 上句错了,改为如下:select table1.* from table1 where (e,f) not in(select a,b from table2); 这样也行:select e, f from table1minusselect a, b from table2; 怎么样都行。select * from table1 where e||f not in (select a||b from table2) select * from table1minusselect * from table2;我试了一下,如果表结构相同的话,用minus也很容易实现例:08:13:47 SQL> select * from a; A_ID1 A_ID2 A_NAME--------- --------- ---------- 1 1 aaa 2 1 A_21 3 1 A_31实际:3008:13:55 SQL> select * from b; A_ID1 A_ID2 B_NAME--------- --------- ---------- 2 1 B_111 1 1 B_112 1 1 aaa实际:2008:13:59 SQL> select * from a08:14:05 2 minus08:14:05 3 select * from b; A_ID1 A_ID2 A_NAME--------- --------- ---------- 2 1 A_21 3 1 A_31实际:2008:14:05 SQL> sorry老眼昏花,Michaelyfj兄已经写了@-@ 阿来说明一下,MINUS是求两个集合的差集的,类似的操作符还有:UNION[ALL]、INTERSECT;其中UNION是求2个集合的并集,加上ALL后选出的结果将包含2个集合中相同的各自的集合记录;INTERSECT是求2个集合的交集。集合操作符在一些方面的查询中是非常高效和灵活的,要掌握。 select * from table1 where not exists(select 1 from table2 where a=e and b=f) 刚学oracle,向大家求助 ORA-29861: 域索引标记为 LOADING/FAILED/UNUSABLE 求助。 powerdesign如何生成升级脚本 问个OCI的问题 那位有oracle rac的资料 sql server数据库迁移到ORACLE! 请问这个时间应该怎么算? 帮我写个触发器? 如何计算两个日期之间的工作日? 吐槽,吐槽。 oracle启动不了!急!!!!(高手请帮忙,在线等待) 备份数据库用存储过程怎样写(请举例)
select table1.* from table1 where (e,f) not in(select a,b from table2);
select e, f from table1
minus
select a, b from table2;
select * from table1 where e||f not in (select a||b from table2)
minus
select * from table2;
我试了一下,如果表结构相同的话,用minus也很容易实现
例:
08:13:47 SQL> select * from a; A_ID1 A_ID2 A_NAME
--------- --------- ----------
1 1 aaa
2 1 A_21
3 1 A_31实际:30
08:13:55 SQL> select * from b; A_ID1 A_ID2 B_NAME
--------- --------- ----------
2 1 B_111
1 1 B_112
1 1 aaa实际:20
08:13:59 SQL> select * from a
08:14:05 2 minus
08:14:05 3 select * from b; A_ID1 A_ID2 A_NAME
--------- --------- ----------
2 1 A_21
3 1 A_31实际:20
08:14:05 SQL>
老眼昏花,Michaelyfj兄已经写了
@-@
其中UNION是求2个集合的并集,加上ALL后选出的结果将包含2个集合中相同的各自的集合记录;
INTERSECT是求2个集合的交集。集合操作符在一些方面的查询中是非常高效和灵活的,要掌握。