1

这是我遇到错误的代码:

FROM
    IndexPID
    INNER JOIN Demographics ON
        IndexPID.NDoc_Number = Demographics.NDoc_Number,
    PatientSupply
    INNER JOIN Demographics ON
        PatientSupply.NDocNum = Demographics.NDoc_Number

我也试过这样:

FROM
    IndexPID, PatientSupply
    INNER JOIN Demographics ON
        IndexPID.NDoc_Number = Demographics.NDoc_Number
    INNER JOIN Demographics ON
        PatientSupply.NDocNum = Demographics.NDoc_Number

但是没有雪茄。有人告诉我我做错了什么吗?

4

4 回答 4

4

如果您发布整个 SQL 会更容易!

尝试

FROM
IndexPID
INNER JOIN Demographics ON
    IndexPID.NDoc_Number = Demographics.NDoc_Number
INNER JOIN PatientSupply ON
    PatientSupply.NDocNum = Demographics.NDoc_Number
于 2012-08-20T20:22:08.863 回答
4

你非常接近:

FROM IndexPID
INNER JOIN Demographics 
   ON IndexPID.NDoc_Number = Demographics.NDoc_Number
INNER JOIN PatientSupply
   ON Demographics.NDoc_Number = PatientSupply.NDocNum
于 2012-08-20T20:22:30.507 回答
2

JOIN在这里以一种奇怪的方式混合了隐式(逗号分隔)和显式 s。它应该如下所示,仅使用显式s,表名或子句INNER JOIN之间没有逗号:ON

FROM
  IndexPID
  INNER JOIN Demographics 
    ON IndexPID.Ndoc_Number = Demographics.NDoc_Number
  INNER JOIN PatientSupply 
    ON PatientSupply.NDocNum = Demographics.NDoc_Number
于 2012-08-20T20:22:01.147 回答
1

您使用内部联接,因此您可以使用:

FROM Demographics
inner join IndexPID on Demographics.NDoc_Number=IndexPID.NDoc_Number
inner join PatientSupply on Demographics.NDoc_Number=PatientSupply.NDocNum
于 2012-08-20T20:30:09.263 回答