When I tried to execute this statement, I got the error. I have created an array mem[]
which contains table names, and in each table there are two columns with names amt(float(9,2))
and comb(varchar(5))
.
I used this statement inside a for loop :
PreparedStatement pst =con.prepareStatement("select sum(amt) from ? where comb = ?");
pst.setString(1,mem[i]);
pst.setString(2, "all");
Error:
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 ''akhil' where comb = 'all'' at line 1
In the error description near akhil and all one side it is showing single quotation and other side double quotation. Why it is showing like that? What exactly is the error?