具有多个连接的嵌套选择语句(MS Access)

时间:2017-12-04 19:22:20

标签: sql ms-access select join nested

我在将在SQL Server Management Studio中运行的查询转移到MS Access时遇到问题。我收到了一个错误:

  

JOIN操作中的语法错误

当我收到此错误时,会突出显示“FROM ProductRun”行。

我认为Access在处理我已经完成的多个Join语句时需要括号。我被卡住了。请帮忙。

SELECT 
    LoadTable.DateTimeStamp, ProgramTable.Value 1, PL.Value 2, PL.Value 3
FROM
    ((LoadTable 
LEFT JOIN 
    ProgramTable ON LoadTable.DateTimeStamp = ProgramTable.DateTimeStamp) 
LEFT JOIN 
    PL ON LoadTable.DateTimeStamp = PL.DateTimeStamp)
LEFT JOIN 
    (SELECT [StartTime], [EndTime]
     FROM ProductRun
     WHERE ProductRun.StartTime >= '11/1/2017' 
       AND ProductRun.Startime <= '12/1/2017') ON (LoadTable.DateTimeStamp >= DATEADD(MINUTE, 15, ProductRun.StartTime) 
                                               AND LoadTable.DateTimeStamp <= DATEADD(MINUTE, -15, ProductRun.EndTime))
ORDER BY 
    LoadTable.DateTimeStamp;

这是我在Management Studio中的嵌套选择语句,它可以正常工作:

LEFT JOIN (SELECT [StartTime] 
      ,[EndTime]
FROM [ProductionReporting].[dbo].ProductRun
 WHERE StartTime between '11/1/2017 12:00:00 AM' and '11/25/2017 12:00:00 AM') as M3
 ON M1.DateTimeStamp between DATEADD(MINUTE,15, M3.StartTime) and DATEADD(MINUTE,-15, M3.EndTime)

1 个答案:

答案 0 :(得分:1)

试试这个:

$('.your-button').on('click', function () {
  const myButton = $(this);

  $.ajax({
    // ...
    success (data) {
      myButton.parent().html(data.PHP_JSON_RECEIVED);

      // or if you need to find a parent further up in the chain
      // myButton.parents('.div_container_to_render_JSON').html(data.PHP_JSON_RECEIVED);
    }
  });
});