select s.orderid,s.empid,e.empname,s.auditor,f.empname
from saleorder s,employee e,employee f
where s.empid = e.empid and s.auditor = f.empid
and s.orderdate between to_date('2004-02-01','yyyy-mm-dd')
amd to_date('2004-02-10','yyyy-mm-dd');
from saleorder s,employee e,employee f
where s.empid = e.empid and s.auditor = f.empid
and s.orderdate between to_date('2004-02-01','yyyy-mm-dd')
amd to_date('2004-02-10','yyyy-mm-dd');
解决方案 »
- 字段类型为NUMBER(10)时1与10000占的存储空间一样吗
- 求帮助!!!!~~~~在SCOTT.EMP表中创建一个触发器:
- IMP-00041 Warning: object created with compilation warnings
- 如何能让oracle的sql语句查询的结果变成3列显示
- ORACLE92的用户密码忘了
- 这个触发器错到哪儿了
- 在pro*c中,无法在表中插入中文,但在sqlplus工具中能插入中文???
- 请各位高手帮助一下!!!
- 我的job怎么不起作用呀,高手请指点
- 关于plsql命令行的问题
- 求助!如何在sql语句中得到两日期之间的天数?
- 新手提问,谢谢,解决马上给分!!
auditor,(select empname from employee tt where tt.empid=t.auditor)
from saleorder t
where orderdate between to_date('20040201','yyyymmdd') and to_date('20040210','yyyymmdd');
,s.auditor,(select distinct f.empname from employee f where s.auditor = f.empid)
from saleorder s
where s.orderdate between to_date('2004-02-01','yyyy-mm-dd')
amd to_date('2004-02-10','yyyy-mm-dd');
select s.orderid,s.empid,e.empname,s.auditor,f.empname
from saleorder s,employee e,employee f
where s.empid = e.empid and s.auditor = f.empid
and s.orderdate between to_date('2004-02-01','yyyy-mm-dd')
amd to_date('2004-02-10','yyyy-mm-dd');第一种方法,我总觉得有问题,因为,如果 这个订单的审批员按照s.auditor = f.empid这个条件查不到,那么通过这个sql就查不到任何结果。
2)这个算法倒是没错,不过总觉得麻烦。
由于saleorder表的auditor引用employee表,是作为外键。
对外键来说:
如果已经被引用,employee表的该条记录删除不掉。
因此,只要s.auditor有数据,就肯定可以找到记录。
但是你说的情况是auditor、s.empid有可能为空,这种情况
比较特殊。
如果这种情况下,你还想将这种记录选择出来,一般采用:
select s.orderid,s.empid,e.empname,s.auditor,f.empname
from saleorder s,employee e,employee f
where s.empid = e.empid(+) and s.auditor = f.empid(+)
and s.orderdate between to_date('2004-02-01','yyyy-mm-dd')
and to_date('2004-02-10','yyyy-mm-dd');
高,高手就是高!呵呵
我就是找这个方法!谢谢了!
csdn就是好,就是好!