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

Igor
34.3k14 gold badges83 silver badges116 bronze badges
asked May 20, 2011 at 20:32

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.

answered May 20, 2011 at 20:35
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.