하은양 믿음군 효실맘 호홍홍집s

여러 테이블 left outer join 처리하기 본문

가벼운 배움/MySql

여러 테이블 left outer join 처리하기

호홍홍집 2016. 12. 26. 19:56

Oracle :

SELECT     

   *********

 FROM TB_RSV RSV, TB_LECTURE LEC, TB_ITEMS ITM, TB_INDATA IND, TB_CODE COD     

 WHERE RSV.RSTATUS IN ('CRD','PRD','NRD','DRD','PER')    

   AND RSV.RSV_ID = IND.RSV_ID  

   AND RSV.OBJ_ID = LEC.LEC_ID(+)    

   AND RSV.OBJ_ID = ITM.ITEM_ID(+)   

   AND RSV.RSTATUS = COD.CD_CODE AND COD.CD_CAT1 = 'RSV'    

   AND RSV.MEM_ID = 'null'     

 ORDER BY RSV.OBJ_TYPE ASC, RSV.OBJ_ID, RSV.STIME;


MySql :

SELECT     

   *********

 FROM TB_RSV RSV LEFT OUTER JOIN TB_LECTURE LEC ON RSV.OBJ_ID = LEC.LEC_ID LEFT OUTER JOIN TB_ITEMS ITM ON RSV.OBJ_ID = ITM.ITEM_ID, TB_INDATA IND, TB_CODE COD     

 WHERE RSV.RSTATUS IN ('CRD','PRD','NRD','DRD','PER')    

   AND RSV.RSV_ID = IND.RSV_ID    

   AND RSV.RSTATUS = COD.CD_CODE AND COD.CD_CAT1 = 'RSV'    

   AND RSV.MEM_ID = 'null'     

 ORDER BY RSV.OBJ_TYPE ASC, RSV.OBJ_ID, RSV.STIME;