select *from spkfk a,hwsp_mx b,hwsp_pc c where a.spid=b.spid and a.spid=c.spid and b.hw=c.hw
第二个查询是select*from spkfk a where (sptm = :v_get OR spbh like :v_zjm OR zjm like :v_zjm OR spmch like :v_zjm OR sptm like :v_zjm )
怎么把两个查询合成一个
我的意思是我要用第二个查询 查询第一个查询到的数据
3 个解决方案
#1
select * from spkfk a,hwsp_mx b,hwsp_pc c
where a.spid=b.spid
and a.spid=c.spid
and b.hw=c.hw
and (a.sptm = :v_get
OR a.spbh like :v_zjm
OR a.zjm like :v_zjm
OR a.spmch like :v_zjm
OR a.sptm like :v_zjm )
#2
加在WHERE条件里面就可以了。
SELECT *
FROM SPKFK A
,HWSP_MX B
,HWSP_PC C
WHERE (A.SPTM = :V_GET
OR A.SPBH LIKE :V_ZJM
OR A.ZJM LIKE :V_ZJM
OR A.SPMCH LIKE :V_ZJM
OR A.SPTM LIKE :V_ZJM )
AND A.SPID=B.SPID
AND A.SPID=C.SPID
AND B.HW=C.HW
#3
正解。OK
#1
select * from spkfk a,hwsp_mx b,hwsp_pc c
where a.spid=b.spid
and a.spid=c.spid
and b.hw=c.hw
and (a.sptm = :v_get
OR a.spbh like :v_zjm
OR a.zjm like :v_zjm
OR a.spmch like :v_zjm
OR a.sptm like :v_zjm )
#2
加在WHERE条件里面就可以了。
SELECT *
FROM SPKFK A
,HWSP_MX B
,HWSP_PC C
WHERE (A.SPTM = :V_GET
OR A.SPBH LIKE :V_ZJM
OR A.ZJM LIKE :V_ZJM
OR A.SPMCH LIKE :V_ZJM
OR A.SPTM LIKE :V_ZJM )
AND A.SPID=B.SPID
AND A.SPID=C.SPID
AND B.HW=C.HW
#3
正解。OK