gpt4 book ai didi

sql - Paradox DB SQL 多重联接

转载 作者:行者123 更新时间:2023-12-03 04:24:14 28 4
gpt4 key购买 nike

我正在开发一个旧版 VB6 项目,我需要进行如下所示的 JOIN 调用:

SELECT C.Cnum, C.RealDate, M.Name, R.Price, R.Qnt, R.RealPrice, R.QntP, R.QntR, M.Name
FROM "CHECK" C
LEFT JOIN "RCHECK" R ON C.Cnum = R.Cnum
LEFT JOIN "PCHECK" P ON C.Cnum = P.Cnum
LEFT JOIN "MONEY" M ON P.Curency = M.Sifr
LEFT JOIN "MENU" MN ON R.Sifr = MN.Sifr
WHERE C.Cnum > 0 ORDER BY C.Cnum

我使用 "Driver={Microsoft Paradox Driver (*.db )};DriverID=538" 作为连接字符串的一部分,但它似乎不支持多个连接!这很奇怪。

有什么想法可以解决/解决这个问题吗?

是的,当我在 Borland Database Desktop 中运行此查询时,它工作得很好。

更新1:

我的 VB 代码:

Dim Conn As New ADODB.Connection
Dim sConnStr As String
Dim sQuery As String

sConnStr = "Driver={Microsoft Paradox Driver (*.db )};DriverID=538;Fil=Paradox 5.X;CollatingSequence=ASCII;DBQ=C:\DBTOFTP\BUFF;DefaultDir=C:\DBTOFTP\BUFF;PWD=SOMEPASS;"

sQuery = "SELECT C.Cnum, C.RealDate, M.Name, R.Price, R.Qnt, R.RealPrice, R.QntP, R.QntR, M.Name " & _
"FROM ""CHECK"" C " & _
"LEFT JOIN ""RCHECK"" R ON C.Cnum = R.Cnum " & _
"LEFT JOIN ""PCHECK"" P ON C.Cnum = P.Cnum " & _
"LEFT JOIN ""MONEY"" M ON P.Curency = M.Sifr " & _
"LEFT JOIN ""MENU"" MN ON R.Sifr = MN.Sifr " & _
"WHERE C.Cnum > 0 " & _
"ORDER BY C.Cnum"

Conn.ConnectionString = sConnStr
Conn.Open

最佳答案

一些老司机经常要求多个JOIN必须用括号括起来。

尝试这样的事情:

FROM 
(
"CHECK" C
INNER JOIN
"RCHECK" R
ON C.Cnum = R.Cnum
)
INNER JOIN
"PCHECK" P
ON P.Cnum = C.Cnum

关于sql - Paradox DB SQL 多重联接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35305904/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com