1
1楼 jeemese 2007-05-17 10:22:39 我有二个表结构一样的表,都有至少200左右的数据,我要查询出二个表中不同的记录,请教下怎么快些? 2楼 jeemese 2007-05-17 10:25:15 sorry,写漏了,200W 3楼 HelloWorld_001 2007-05-17 11:23:43 简单的话 假设id关联,A表纪录少 找出A表不存在,B表存在的纪录 select B.* from B where not exists(select 'Z ' from A where A.id=B.id) 有个其他的方法 select A.id,B.id from A,B where A.id(+)=B.id and A.id is null 如果2表都可能缺少 select A.*, 'A ' from A union select B.*, 'B ' from B minus select A.*, 'AB ' from A,B where A.id=B.id 没测试,仅工参考 4楼 precipitant 2007-05-17 13:42:16 (select * from b minus select * from a) union (select * from a minus select * from b) 5楼 precipitant 2007-05-17 13:43:49 上半部分是 b中有 而 a 中没有的记录 下半部分是 a中有 而 b 中没有的记录 用union 加起来 就是 两个表中 全部不同的记录的集合 6楼 jeemese 2007-05-17 13:47:48 谢谢,我先测试下,想要执行快点的方法!
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源
| |||||