MS Access中的循环引用

时间:2013-05-19 07:46:10

标签: sql ms-access ms-access-2007

我在Microsoft Access SQL中收到循环引用错误。

SELECT a.PlateNo, a.colm, a.alain
FROM (SELECT PlateNo, alain, min(InspectionDate) AS colm
      FROM [Vehicle Spot Check] GROUP BY PlateNo)
  AS a
INNER JOIN [Vehicle Spot Check] AS m
ON (a.alain = m.WithoutDefects) AND (a.colm = m.InspectionDate)
  AND (a.PlateNo = m.PlateNo);

我收到了这个错误:

Circular reference caused by alias '' in query definition's Select List. 

我不知道哪一个,因为没有指定的字段。我的主要嫌疑人是m.WithoutDefects,但我已经仔细检查过了。有没有办法找到这个?我所想的也是“内部加入”之后的语法问题。

2 个答案:

答案 0 :(得分:0)

我怀疑它与你的" AS"中的任何一个或两个都有关。如果您有一个名为colmm的列,则无法将结果命名为" AS"作为当前列值。尝试将colmm替换为其他内容,例如colm_m_

SELECT a.PlateNo, a.colm, a.alain
FROM (SELECT PlateNo, alain, min(InspectionDate) AS colm_
      FROM [Vehicle Spot Check] GROUP BY PlateNo)
  AS a
INNER JOIN [Vehicle Spot Check] AS m_
ON (a.alain = m.WithoutDefects) AND (a.colm = m.InspectionDate)
  AND (a.PlateNo = m.PlateNo);

答案 1 :(得分:0)

我来自印度的 Bh​​anu Bhanot

使用这个

  

SELECT E.id AS ID,          E.dte AS Date,          E.Billno AS'Bill No',          E.LRno AS'LR No',          P1.PartyName AS'发件人派对',          E.Qty,          E.PVT_Marka AS'PVT Marka',          P2.PartyName AS'接收方',          E.Amount,          E.CGST,          E.SGST,          E.IGST,          E.TotalAmount AS'总金额'FROM(条目AS E.        INNER JOIN Party AS P1 ON E.PartySenderId = P1.id)        LEFT JOIN Party AS P2 ON E.PartyReceiverId = P2.id ORDER BY E.id;

不是这个

  

SELECT id AS ID,          E.dte AS Date,          E.Billno AS'Bill No',          E.LRno AS'LR No',          P1.PartyName AS'发件人派对',          E.Qty,          E.PVT_Marka AS'PVT Marka',          P2.PartyName AS'接收方',          E.Amount,          E.CGST,          E.SGST,          E.IGST,          E.TotalAmount AS'总金额'FROM(条目AS E.        INNER JOIN Party AS P1 ON E.PartySenderId = P1.id)        LEFT JOIN Party AS P2 ON E.PartyReceiverId = P2.id ORDER BY id;

原因

id字段存在于EntryParty表中。要识别该表,应指定E.id而不是id

正在工作..