1
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

1 Answer 1

10
" and Year(visits.VisitTime)=" + year + "GROUP BY ...

Should be:

" and Year(visits.VisitTime)=" + year + " GROUP BY ...

Your version is missing a space before GROUP.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.