SQL语句如何查B关系中某字段不为0的A关系 两个关系A与B,一对多。A包含关键字n,B包含字段n和m,n与m可决定B。n可取值a,b,c,……m可取值0,1,2,……求一SQL语句,查两表联立后m不为0的n。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select a.n from a a, b b where a.n = b.n and b.m <> 0 group by a.n select a.n from a,(elect distinct n from b minusselect distinct n from b where m=0) bwhere a.n=b.n 要看lz的需求了还有就是,b表的n 是不是a表的n子集如果是的话,就不需要关联a表了,这样速度会更快 select * from a where exists (select 1 from b where n=a.n and m<>0) 怎样查看日志 请大师们帮改一下 [求助] sqlplus中edit的问题 Oracle8 Nvarchar2字段类型读取错误 弱弱的问下数据库中什么是基于成本的优化(急!) 请教:Oracle做全外连接的表的个数,是否有限制 用OleDb连接Oracle,如何用Parameters传递参数? 请问上海软件公司程序员的工资有多少?? 存储过程中有关常量的处理? PLsql 出现“ 找不到IS” “ 找不到oERRORCODE”错误 强人,快了帮帮忙,提示expected UDT got NUMBER 从数据库中查询空格
from a a, b b
where a.n = b.n
and b.m <> 0
group by a.n
(elect distinct n from b
minus
select distinct n from b where m=0) b
where a.n=b.n
还有就是,b表的n 是不是a表的n子集
如果是的话,就不需要关联a表了,这样速度会更快