0
當我試圖執行此聲明,我得到了錯誤。我創建了包含表名的數組mem[]
,並在每個表中有兩列名amt(float(9,2))
和comb(varchar(5))
。錯誤,同時使用preparedstatement
我用這個語句中一個for循環:
PreparedStatement pst =con.prepareStatement("select sum(amt) from ? where comb = ?");
pst.setString(1,mem[i]);
pst.setString(2, "all");
錯誤:
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
在附近AKHIL錯誤描述和所有一面是露出單引號和對方雙引號。它爲什麼這樣展示? 錯誤究竟是什麼?
我必須訪問6 tables.is有任何方法來寫代碼很快,而不是分別寫每個表 –