如何将第一个查询的结果与表和表的EMPLID
列匹配的第二个查询结合起来?Z_EMP_YAN
Z_OPRDEFN
select b.OPRID
from Z_EMP_BENFT a, PSOPRDEFN b
WHERE a.EMPLID = b.EMPLID
AND A.Z_PEND_COVER = 'Y'
AND OPRID LIKE 'ZZ%'
select EMPLID from z_emp_yan where z_yan_action_id = 1
如何将第一个查询的结果与表和表的EMPLID
列匹配的第二个查询结合起来?Z_EMP_YAN
Z_OPRDEFN
select b.OPRID
from Z_EMP_BENFT a, PSOPRDEFN b
WHERE a.EMPLID = b.EMPLID
AND A.Z_PEND_COVER = 'Y'
AND OPRID LIKE 'ZZ%'
select EMPLID from z_emp_yan where z_yan_action_id = 1
上一篇文章没什么问题,我只是更喜欢使用Joins
:
select b.oprid
from ps_z_emp_benft a
join psoprdefn b on a.emplid = b.emplid
join ps_z_emp_yan c on a.emplid = c.emplid
where A.z_pend_cover = 'Y'
and oprid LIKE 'ZZ%'
and c.z_yan_action_id = 1
试试这个
SELECT b.oprid
FROM ps_z_emp_benft a,
psoprdefn b,
ps_z_emp_yan c
WHERE a.emplid = b.emplid
AND a.emplid = c.emplid
AND A.z_pend_cover = 'Y'
AND oprid LIKE 'ZZ%'
AND c.z_yan_action_id = 1