我想像这样在oracle数据库中过滤我的数据,我知道这个查询是错误的,是否有其他任何可能的方法来执行此操作? 目前我正在尝试这样做。
SELECT apd.first_name,
apd.middle_name,
apd.last_name,
apd.first_thi_nme,
apd.middle_thi_nme,
apd.last_thi_nme
FROM applicant_detail apd
WHERE apd.application_number IN
( SELECT **apd.application_number,
apd.industry_type_cde**
FROM a_detail apd,
a_type apt
WHERE apt.application_number=apd.application_number
AND apt.identification_code=apd.identification_code
AND apt.guarantor_type='I' )
//我必须在这两个列基础上找到重新编码,其中两个列相同,它们返回唯一或任何其他方式来传递apd.application_number
中的apd.industry_type_cde
,IN
或任何其他方式其他
我知道如何做到这一点?
答案 0 :(得分:3)
我正在使用mysql和postgresql以下工作正常我认为它也适用于oracle
WHERE (column1,column2) IN ( select col1,col2 .....rest of the query)
答案 1 :(得分:0)
试试这个
WHERE apd.application_number in
(select apd.application_number FRoM ...)
OR
apd.application_number in
(select apd.industry_type_cde FROM ...)
答案 2 :(得分:0)
你可以使用联盟:
select apd.application_number
from a_detail apd,a_type apt
where
apt.application_number=apd.application_number and
apt.identification_code=apd.identification_code and
apt.guarantor_type='I'
UNION
select apd.industry_type_cde
from a_detail apd,a_type apt
where
apt.application_number=apd.application_number and
apt.identification_code=apd.identification_code and
apt.guarantor_type='I'
答案 3 :(得分:0)
最好显示表格架构。但 JOIN
可以模拟IN
:)
SELECT apd.first_name,
apd.middle_name,
apd.last_name,
apd.first_thi_nme,
apd.middle_thi_nme,
apd.last_thi_nme
FROM applicant_detail apd
JOIN
(SELECT apd.application_number,
apd.industry_type_cde
FROM a_detail apd
INNER JOIN
a_type apt
ON apt.application_number=apd.application_number
WHERE apt.identification_code=apd.identification_code
AND apt.guarantor_type='I' ) as X
ON apd.application_number = CONCAT(X.application_number, X.industry_type_cde)
;