第一条:
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')当然是返回三条记录啦。
解决方案 »
- oracle中PL-SQL中如何循环输入参数?
- oracle删除特定重复记录
- oracle缓存太小
- 发现某张表被锁住了,怎么解决?
- 語句優化!
- 客户端如何使用命令行rman对服务器端数据库做备份
- 一个加了判断的复杂存储过程,各位帮我看看啊~~~
- help me.................
- 各位:请告诉我oracle8.1.5能够安装在win2k professal上吗?
- 各位位大哥知道数据库中的代理键是什么?怎么使用?能详细的给我讲讲么?回帖的都有分!3ks!
- 开始菜单下怎么没有反映呀(如: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(+)
难道不能马上给分吗?