String sql = "SELECT siteapplications.Application, Count(visits.VisitId) AS CountOfVisitId
FROM visits, siteapplications
WHERE visits.SiteApplicationId=siteapplications.ApplicationID
and Month(visits.VisitTime)=" + month + "
and Year(visits.VisitTime)=" + year +
"GROUP BY siteapplications.Application
ORDER BY CountOfVisitId DESC;";
rs = st.executeQuery(sql);
When I run it I get this error in java :
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 'BY Application ORDER BY CountOfVisitId DESC' at line 1
I don't see a error ...
Can anyone help ...
thx all
Igor
34.3k14 gold badges83 silver badges116 bronze badges
asked May 20, 2011 at 20:32
Darth Blue Ray
9,78510 gold badges37 silver badges49 bronze badges
1 Answer 1
" and Year(visits.VisitTime)=" + year + "GROUP BY ...
Should be:
" and Year(visits.VisitTime)=" + year + " GROUP BY ...
Your version is missing a space before GROUP.
answered May 20, 2011 at 20:35
Kevin Peno
9,2261 gold badge36 silver badges56 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default