SQL左串連

來源:互聯網
上載者:User

SELECT b.c_dpt_cde      as CDptCde,
       a.c_prod_no      as CProdNo,
       a.c_ply_no       as CPlyNo,
       a.c_edr_no       as CEdrNo,
       a.c_insrnt_cde   as CInsrntCde,
       a.c_bs_cur       as CBsCur,
       a.n_bs_amt       as NBsAmt,
       a.n_exch_rate    as NExchRate,
       a.c_rp_cur       as CRpCur,
       a.n_rp_amt       as NRpAmt,
       a.n_orig_cur_amt as NOrigCurAmt,
       a.c_main_con_cde as CMainConCde,
       a.c_sls_cde      as CSlsCde,
       a.c_cha_cls      as CChaCls,
       a.c_cha_cde      as CChaCde,
       b.c_oper_cde     as COperCde,
       b.t_cav_tm       as TCavTm,
       b.t_upd_tm       as TUpdTm,
       a.c_cav_pk_id    as CCavPkId,
       c.c_rp_type      as CRpType,
       b.c_check_cde    as CCheckCde,
       b.t_check_tm     as TCheckTm,
       b.c_check_flag   as CCheckFlag,
       b.c_check_memo   as CCheckMemo,
       a.c_prmdue_pk_id as CPrmduePkId,
       a.c_paydue_pk_id as CPayduePkId,
       a.c_clmdue_pk_id as CClmduePkId,
       a.c_cavdoc_pk_id as CCavdocPkId,
       a.c_clm_no       as CClmNo,
       a.c_bill_flag    as CBillFlag,
       a.c_feetyp_cde   as CFeetypCde
  FROM web_fin_cav_doc a
  left join web_fin_cav_bill b on a.c_cav_pk_id = b.c_cav_pk_id
  left join web_fin_cav_rptyp c on a.c_cav_pk_id = c.c_cav_pk_id
 WHERE 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1
   AND 1 = 1;

 

上面實現的是三個資料表之間的左串連。以前看見過兩個表的左串連,而要實現三個表之間的左串連,還真有點困難,搞了半天才做出來。。。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.