Originally posted by: notfred
How is that a JSP question?
Originally posted by: Cerebus451
According to the docs, AVG is an aggregate function, meaning that you have to have a GROUP BY column. Add a GROUP BY p.team into your query.
EDIT: After reading it closer, it appears you don't need the GROUP BY (which means perform across all rows), so I'm not sure.
EDIT2: What specific error message is being returned?
Originally posted by: bunker
make sure teamid actually has a value in it.
Try running it by substituting an acutal number for the variable.
Originally posted by: haris
Does the query run outside of the jsp page?
If so, did you check to make sure that the DB connection is working by using a simple statement like "select * from players;"?
The only other thing that jumps out at me right now is you might need to add + ";" after the teamid.
Originally posted by: Homerboy
Originally posted by: haris
Does the query run outside of the jsp page?
If so, did you check to make sure that the DB connection is working by using a simple statement like "select * from players;"?
The only other thing that jumps out at me right now is you might need to add + ";" after the teamid.
it runs inside the .jsp
I've tried it with completly removing the + teamid and editing with "WHERE team = 2"
The fact that the error message includes java code instead of simply the contents of the string seems really odd. Could you post the stack trace and the section of code surrounding this call?Originally posted by: Homerboy
there are other queries already running on the page with no problems (not to mention a few dozen other pages through the site that work n/p)
Ive tried entering the query (with no "teamid") directly into mySQL front and get the error I posted above:
ResultSet teamovr = stmt.executeQuery("SELECT AVG(ovrl) AS averageovrl FROM players WHERE team = 2")
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 'ResultSet teamovr = stmt.executeQuery("SELECT AVG(ovrl) AS aver