断点

每天进步一点点!
posts - 174, comments - 56, trackbacks - 0, articles - 21

SQL左连接

Posted on 2010-01-14 22:09 断点 阅读(404) 评论(0)  编辑  收藏 所属分类: SQL

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;

 

上面实现的是三个数据表之间的左连接。以前看见过两个表的左连接,而要实现三个表之间的左连接,还真有点困难,搞了半天才做出来。。。


posted @ 2009-02-27 09:50 断点 阅读(356) | 评论 (0)

只有注册用户登录后才能发表评论。


网站导航: