MYSQL SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误

时间:2013-07-11 13:09:00

标签: mysql mysql-error-1064

我收到以下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)"

建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

]. AS不是SQL正确的表达式(似乎您使用microsoft访问来创建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)