조건절서브쿼리오류

by ozro posted Aug 12, 2022


* 질문 등록 시 다음의 내용을 꼭 기입하여 주세요.

OS
 Linux 64bit 등
CUBRID Ver.
11.2
CUBRID TOOL Ver.
sqlgate
응용 환경(API)
 


* CUBRID 응용 오류, SQL 오류 또는 SQL 튜닝 관련된 문의는 반드시 다음의 내용을 추가해 주세요. 비밀글이나 비밀 댓글도 가능합니다.
* 저희가 상황을 이해하고, 재현이 가능해야 알 수 있는 문제들이 많습니다. 가능한 정보/정황들을 부탁합니다.

 

에러 내용 및 재현 방법 재현 가능한 Source와 SQL
관련 테이블(인덱스, 키정보 포함) 정보 CUBRID 홈 디렉토리 아래 log 디렉토리 압축


-------------- 아래에 질문 사항을 기입해 주세요. ------------------------------------------------------------------------

select *
from cg_reg_info t1 left outer join cg_ers_his t2
                                        on t1.lnd_r  = t2.lnd_r
                                       and t1.lnd_no = t2.lnd_no
                                       and t1.app_yr = t2.app_yr
                                       and t1.app_no = t2.app_no
                                       and t1.reg_no = t2.reg_no
                                       and t2.ser_no  =  (select max(ser_no) from cg_ers_his 
                                                     where lnd_r = t1.lnd_r and lnd_no = t1.lnd_no
                                                       and app_yr= t1.app_yr and app_no = t1.app_no
                                                       and reg_no = t1.reg_no 
                                                       and reg_dt = (select max(reg_dt) from cg_ers_his 
                                                                                         where lnd_r = t1.lnd_r and lnd_no = t1.lnd_no
                                                                                       and app_yr= t1.app_yr and app_no = t1.app_no
                                                                                       and reg_no = t1.reg_no)
                                                             )
WHERE t1.app_yr = '2022' AND t1.app_no = '50001'  

 

-----------------------------------------------------------------------------------------------------------------------------------

에러

Cannot use a subquery in join condition clause. 

이 부분 지우면 제대로 실행

and t2.ser_no  =  (select max(ser_no) from cg_ers_his 
                                                     where lnd_r = t1.lnd_r and lnd_no = t1.lnd_no
                                                       and app_yr= t1.app_yr and app_no = t1.app_no
                                                       and reg_no = t1.reg_no 
                                                       and reg_dt = (select max(reg_dt) from cg_ers_his 
                                                                                         where lnd_r = t1.lnd_r and lnd_no = t1.lnd_no
                                                                                       and app_yr= t1.app_yr and app_no = t1.app_no
                                                                                       and reg_no = t1.reg_no)
                                                             )

 

-----------------------------------------------------------------------------------------------------------------------------------

 

where 절에 서브쿼리가 지원이 안되나요????

 

 

select *
from cg_reg_info t1 left outer join cg_ers_his t2
                                        on t1.lnd_r  = t2.lnd_r
                                       and t1.lnd_no = t2.lnd_no
                                       and t1.app_yr = t2.app_yr
                                       and t1.app_no = t2.app_no
                                       and t1.reg_no = t2.reg_no
                                       and t2.ser_no  IN  (1,2
                                                       
                                                             )
WHERE t1.app_yr = '2022' AND t1.app_no = '50001'

 

--> 제대로 실행

 

select *
from cg_reg_info t1 left outer join cg_ers_his t2
                                        on t1.lnd_r  = t2.lnd_r
                                       and t1.lnd_no = t2.lnd_no
                                       and t1.app_yr = t2.app_yr
                                       and t1.app_no = t2.app_no
                                       and t1.reg_no = t2.reg_no
                                       and t2.ser_no  IN  (select ser_no from cg_ers_his  a
                                                     where a.lnd_r = t1.lnd_r and a.lnd_no = t1.lnd_no
                                                       and a.app_yr= t1.app_yr and a.app_no = t1.app_no
                                                       and a.reg_no = t1.reg_no 
                                                       
                                                             )
WHERE t1.app_yr = '2022' AND t1.app_no = '50001'    

 

--> 에러, Cannot use a subquery in join condition clause.                                                                                         

 

 

 

 

 


Articles

1 2 3 4 5 6 7 8 9 10