I have the following code but cant seem to trace where the error is coming from. Thank you for your help.
String userID= (String) session.getAttribute("userID");
String query1 = "SELECT (A.Leave - sum(B.Duration)) AS BALANCE_LEAVE FROM users A, leave B WHERE A.userID=B.userID AND A.userID = '" + userID + "'";
rst1 = stm1.executeQuery(query1);
The error is
javax.servlet.ServletException: 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 'leave B WHERE A.userID=B.userID AND A.userID = 'staff'' at line 1