例1:select * from table1 where id =(select id from table1);
由于子查询结果中有多行,但是where条件id = 只能有一行记录
例2: select (select name from emp where a.job = b.job) from emp
由于 子查询的结果是多列 但是select 应该选择 其中一列
关联查询:
select w.id,r.id,w.appno,w.sgappno,bb.handle_context,
--单纯需要把数字代码转换成汉字,需要翻译表时w.orgno = orgcode 找出对应的数据字典
(select orgname from org_orgnization where orgcode = w.orgno) orgname
from s_wkst w, bb
where w.appno = bb.appno
and tochar(w.handle_time,'yyyy-mm-dd') >='2018-08-01'
and tochar(w.handle_time,'yyyy-mm-dd') <='2018-08-30'
and w.orgno like '41404' || '%'