2

私はこのクエリを Microsoft Access SQL で記述しようとしていますが、私の人生では、コードの構文エラーを理解できません。

SELECT base.study_group, base.NPI,inv.log_date AS invite_date, rec.log_date as
recieved_date, rej.log_date as reject_date
FROM CODAAC_master AS base
LEFT JOIN Pre_Log AS inv ON base.NPI = inv.NPI AND inv.tracking_event='INVA'
LEFT JOIN Pre_Log AS rec ON base.NPI = rec.NPI AND rec.tracking_event='RECA'
LEFT JOIN Pre_Log AS rej ON base.NPI = rej.NPI AND rej.tracking_event='REJA'
WHERE base.study_year = '2013'
ORDER BY base.study_group, base.NPI;

私が返すエラーは次のとおりです。

"Syntax error (missing operator) in query expression"
4

2 に答える 2

3

MS Access では、複数の結合を括弧で囲む必要があります。

SELECT base.study_group, 
  base.NPI,
  inv.log_date AS invite_date, 
  rec.log_date as recieved_date, 
  rej.log_date as reject_date
FROM ((CODAAC_master AS base
LEFT JOIN Pre_Log AS inv 
  ON base.NPI = inv.NPI AND inv.tracking_event='INVA')
LEFT JOIN Pre_Log AS rec 
  ON base.NPI = rec.NPI AND rec.tracking_event='RECA')
LEFT JOIN Pre_Log AS rej 
  ON base.NPI = rej.NPI AND rej.tracking_event='REJA'
WHERE base.study_year = '2013'
ORDER BY base.study_group, base.NPI;
于 2013-03-29T14:36:47.653 に答える
3

MS Access では必須であるため、結合の間に括弧を追加する必要があります。(これは他の RDBMS ではオプションです)

SELECT  base.study_group, 
        base.NPI,
        inv.log_date AS invite_date, 
        rec.log_date as recieved_date, 
        rej.log_date as reject_date
FROM  ((CODAAC_master AS base LEFT JOIN Pre_Log AS inv 
            ON base.NPI = inv.NPI AND inv.tracking_event='INVA')
        LEFT JOIN Pre_Log AS rec 
            ON base.NPI = rec.NPI AND rec.tracking_event='RECA')
        LEFT JOIN Pre_Log AS rej 
            ON base.NPI = rej.NPI AND rej.tracking_event='REJA'
WHERE base.study_year = '2013'
ORDER BY base.study_group, base.NPI;
于 2013-03-29T14:36:48.570 に答える