shaf Posted March 15, 2015 Share Posted March 15, 2015 I have table customer in which, one of the columns is start_Date of data type Date. I've tried running it but no rows were selected. I wonder if it is because my queries were wrong.So here, I wanted to create a monthly and yearly report which takes input("month" and "year") from the user. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ String year = request.getParameter("year"); String month = request.getParameter("month");String query = "SELECT EXTRACT(YEAR FROM start_Date) AS start_Year," + "EXTRACT(MONTH FROM start_Date) AS start_Month, " + "FROM customer"; statement = con.createStatement(); ResultSet result = statement.executeQuery(query); while (result.next()) { String query4 = "SELECT * FROM customer WHERE status_Order='Paid'" + ",start_Month='" +month+ "' AND start_Year='" +year+ "'"; statement4 = con4.createStatement(); ResultSet rs4 = statement4.executeQuery(query4); Link to comment Share on other sites More sharing options...
justsomeguy Posted March 16, 2015 Share Posted March 16, 2015 It looks like the comma before start_Month would cause a problem, you probably need AND or OR there. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now