• access的多个left outer join连接


    虽然你有一万个理由,但是选择ACCESS数据库就是一个不能再蠢的决定。

    从AC990账务系统中采集凭证记录,需要做多个左连接。在sql server管理器中执行蛮好,没有问题。可是在程序中就一堆Error。

    说左连接。下面代码在管理器查询中执行是ok的。

    select (replace(c.pzrq,'.','')+ a.pzlx +right('00000'+cast(a.pzh as varchar(5)),5)) as HDCD_ID,
    '101' as HDCD_TypeCode, 
    '人员经费' as HDCD_TypeName,
    c.pzrq as HDCD_Date,
    a.zy as HDCD_Summary,
    a.kmdm as HDCD_DetailCode,
    b.kmmc as HDCD_DetailName,
    a.je as HDCD_DetailSum,
    'ac990财务软件' as HDCD_Source,
    a.pzh as HDCD_SourceNo,
    '科室代码' as HD_No,
    '科室名称' as HDCD_DeptName,
    '科室大类' as HDCD_DeptType
    from
    (select * FROM [AC990财务软件]...[ID0000_PZGL_D] where  kjn=2021 and kjy=10 and kmdm='100101'
    ) a
    left outer join [AC990财务软件]...[ID0000_YE] b on (a.kmdm=b.kmdm and b.kjn=2021 and b.kjy=10)
    left outer join [AC990财务软件]...[ID0000_PZGL_M] c on (a.pzh=c.pzh and c.kjn=2021 and c.kjy=10)
    order by a.pzh

    在程序中就出错。错误有二个:

    1、函数不识别。access有自己简单的函数。需要按照access自己的函数进行修改

    2、数据表的表达,不识别。改成标标准格式

    3、左连接表达式错误。每个left join需要括号()成对括起来:from ( (  T1 left join T2  on ...)left join T3  on...)

    我们改一下:

    select '101' as HDCD_TypeCode, 
    '人员经费' as HDCD_TypeName,
    c.pzrq as HDCD_Date,
    a.zy as HDCD_Summary,
    a.kmdm as HDCD_DetailCode,
    b.kmmc as HDCD_DetailName,
    a.je as HDCD_DetailSum,
    'ac990财务软件' as HDCD_Source,
    a.pzh as HDCD_SourceNo,
    '科室代码' as HD_No,
    '科室名称' as HDCD_DeptName,
    '科室大类' as HDCD_DeptType
    from
    (
    (
    (
    select * FROM ID0000_PZGL_D where kjn=2021 and kjy=10 and kmdm='100101' ) a left outer join ID0000_YE b on (a.kmdm=b.kmdm and b.kjn=2021 and b.kjy=10)
    )
    left outer join ID0000_PZGL_M c on (a.pzh=c.pzh and c.kjn=2021 and c.kjy=10)
    )
    order by a.pzh
  • 相关阅读:
    dos命令连接mysql并且查看编码方式
    node.js 好博客
    node.js 连接数据库
    express的基本配置项
    express 手册
    VPS巴士
    nodejs书籍
    nodejs connect模块
    网站工具,如天气,手机归属地
    NodeJS的异步编程风格
  • 原文地址:https://www.cnblogs.com/usegear/p/15405351.html
Copyright © 2020-2023  润新知