我正在尝试构建一个连接三个表的查询,我想通过VBscript运行此查询。
这是我的工作版本:
sSQL = "SELECT OPNPOS.FUND, SECRTY.TKR, SECRTY.ISIN, OPNPOS.QTY, OPNPOS.LCL_ACCINC, PRIHST.PRICE / SECRTY.FACTOR AS CENA FROM (OPNPOS INNER JOIN SECRTY ON OPNPOS.TKR = SECRTY.TKR) INNER JOIN PRIHST ON SECRTY.TKR = PRIHST.TKR WHERE OPNPOS.FUND IN " & sFUND & " AND PRIHST.PRCDATE = #" & sDATA & "# ORDER BY OPNPOS.FUND"
我需要更改此查询以查看OPNPOS表中的每个元素,以便我更改
FROM OPNPOS INNER JOIN
为:
FROM OPNPOS LEFT JOIN
但它给了我一个错误。 错误:不支持连接表达式。 代码:80004005
我知道有一些方法可以解决这个问题但是我已经尝试了很多组合而没有成功; /
任何人都可以帮助我?
这是我的VBScript的一个重要部分:
Option Explicit
dim sDATA
sDATA = InputBox("Podaj datę w formacie MM/DD/YYYY.")
dim sPATH
sPATH = "M:\MFWIN\Data"
dim sFUND
sFUND = "('FOM','KRAKOWIA')"
dim sSQL
sSQL = "SELECT OPNPOS.FUND, SECRTY.TKR, SECRTY.ISIN, OPNPOS.QTY, OPNPOS.LCL_ACCINC, PRIHST.PRICE / SECRTY.FACTOR AS CENA FROM (OPNPOS INNER JOIN SECRTY ON OPNPOS.TKR = SECRTY.TKR) INNER JOIN PRIHST ON SECRTY.TKR = PRIHST.TKR WHERE OPNPOS.FUND IN " & sFUND & " AND PRIHST.PRCDATE = #" & sDATA & "# ORDER BY OPNPOS.FUND"
dim conn, rs
Set conn = createobject("adodb.connection")
Set rs = createobject("adodb.recordset")
conn.Open "Driver={Microsoft dBASE Driver (*.dbf)};SourceType=DBF;Dbq="&sPATH
rs.Open sSQL,conn
答案 0 :(得分:0)
我认为这是因为你需要说:
Left Outer Join
而不仅仅是
Left Join