I am new here. I have some issue in my sql query. I am writing sql query in my java code. i am struggling in figuring out the correct syntax of the query. My query is
PreparedStatement statement = con.prepareStatement("" + "Select Transaction_ID, Transaction_Value, Transaction_Type, Description " + "from Banking " + "limit ? " + "where MIN(Transaction_Value) = ? AND " + "MAX(Transaction_Value) = ? "); //setting the limit of records, minimum and maximum values specified by the user statement.setInt(1, num); statement.setInt(2, min); statement.setInt(3, max); ResultSet result = statement.executeQuery();
When I execute this query, it prompt an error message that
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'MIN(Transaction_Value) = 5 AND MAX(Transaction_Value) = 100' at line 1..
Your help will be really appreciated. I am really very much struggling. I have used simple queries before but dot know how to fix that error.
Thank you so much in advance.