第一条:
where a.userid in ('2', '3', '64') 有三条记录
where a.userid in ('2', '3', '64') and a.userid = b.xmjlbh(+) 有三条记录,但和表sl_hc_xqd相关的信息是null,
最后加上条件b.djztid in ('02', '03'),当然什么记录都没有了。
--------------------------
第二条:就不同了,虽然作了左连接后和表sl_hc_xqd相关的信息是null,
但加上条件a.userid in ('2', '3', '64')当然是返回三条记录啦。
where a.userid in ('2', '3', '64') 有三条记录
where a.userid in ('2', '3', '64') and a.userid = b.xmjlbh(+) 有三条记录,但和表sl_hc_xqd相关的信息是null,
最后加上条件b.djztid in ('02', '03'),当然什么记录都没有了。
--------------------------
第二条:就不同了,虽然作了左连接后和表sl_hc_xqd相关的信息是null,
但加上条件a.userid in ('2', '3', '64')当然是返回三条记录啦。
解决方案 »
- Oracle11g 已经安装后添加新功能
- 关于CLEAR的问题。。
- oracle aq 可以入队但是出队的时候为空,我快崩溃了!
- 如何用powerdesigner重oracle数据库反转生成概念数据模型?
- 数据备份
- 如何用sql取二级域名?急100分
- 哪里有精简版的Oracle数据库服务器下载?
- REPORT的格式问题
- 如何界定大型数据库和超大型数据库的区别?
- Oracle\SQL*Plus中如何知道一个表中的记录条数,这句SQL怎么写?
- 开始菜单下怎么没有反映呀(如:Net 8 assistan , Net 8 ,Universal install))
- 请问在Oracal的PL/SQL中如何获得精确到百分之一秒的时间信息(能精确到千分之一秒更好)?
不要先写select ...
而应先写from ... where ...
select a.userid, a.username, count(b.djid) as xqd
from userinfo a, sl_hc_xqd b
where b.djztid in ('02', '03')
and a.userid = b.xmjlbh(+)
and a.userid in ('2', '3', '64')
group by a.userid, a.username
select a.userid,a.username,count(b.djid) xqd from
(select userid,username
from userinfo where a.userid in ('2', '3', '64') group by userid,username) a
(select * from sl_hc_xqd where djztid in ('02', '03')) b
where a.userid = b.xmjlbh(+)
难道不能马上给分吗?