我收到以下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)"
建议将不胜感激。
答案 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)