1

我在 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,但我已经仔细检查过。有没有办法找到这个?我在想的也是“Inner Join”之后的语法问题。

4

2 回答 2

0

我是来自印度的Bhanu Bhanot

用这个

SELECT E.id AS ID, E.dte AS Date, E.Billno AS 'Bill No', E.LRno AS 'LR No', P1.PartyName AS 'Sender Party', E.Qty, E.PVT_Marka AS 'PVT Marka', P2.PartyName AS 'Receiver Party', E.Amount, E.CGST, E.SGST, E.IGST, E.TotalAmount AS 'Total Amount' FROM(Entry 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 'Sender Party', E.Qty, E.PVT_Marka AS 'PVT Marka' , P2.PartyName AS 'Receiver Party', E.Amount, E.CGST, E.SGST, E.IGST, E.TotalAmount AS 'Total Amount' FROM(Entry 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

这是工作..

于 2017-10-16T20:31:10.367 回答
0

我怀疑这与您的“AS”中的一个或两个有关。如果您有一个名为colmor的列m,则不能将“AS”的结果命名为当前列值。尝试将colmand替换为m其他内容,例如colm_and 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);
于 2017-09-27T17:30:50.997 回答