0

我收到以下 MYSQL 错误消息。

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET BusRunDetailsID, BusRunDetails.BusRunID SET BusRunID, BusRunDetails.Meterag' at line 1

"SELECT [BUSRUNDETAILS.busrundetailsid] as busrundetailsid, ".
" [BUSRUNDETAILS.BUSRUNID] as busrunid, round(BUSRUNDETAILS.Meterage,2) as max_meterage, ".
" BUSRUNDETAILS.StopNo as max_stopno ".
" FROM BUSRUNDETAILS INNER JOIN ".
" [SELECT r.BUSRUNID, max(R.STOPNO) As MAXSTOP ".
" FROM BUSRUNDETAILS AS R ".
" GROUP BY R.BUSRUNID]. AS T2 ON ".
"(BUSRUNDETAILS.StopNo = T2.maxstop) AND ".
"(BUSRUNDETAILS.BusRunId = T2.BUSRUNID)"

建议将不胜感激。

4

1 回答 1

0

]. AS不是 SQL 正确的表达式(您似乎正在使用 microsoft access 来创建您的 SQL)

SELECT [BUSRUNDETAILS.busrundetailsid] as busrundetailsid,
       [BUSRUNDETAILS.BUSRUNID] as busrunid, 
       round(BUSRUNDETAILS.Meterage,2) as max_meterage, 
       BUSRUNDETAILS.StopNo as max_stopno 
FROM BUSRUNDETAILS 
INNER JOIN 
    (SELECT r.BUSRUNID, 
            max(R.STOPNO) As MAXSTOP 
     FROM BUSRUNDETAILS AS R 
     GROUP BY R.BUSRUNID) AS T2 
ON (BUSRUNDETAILS.StopNo = T2.maxstop) 
AND (BUSRUNDETAILS.BusRunId = T2.BUSRUNID)
于 2013-11-26T23:03:54.847 回答