2013-09-30 57 views
0

我試圖當我運行程序我收到以下錯誤控制檯如何在MySQL數據庫中更新查詢


錯誤在mysql數據庫用下面的代碼 更新:

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 
'SET AVG_COST = 100000 , RWDS_INCENT = 200 , OTH_EXPENSES = 10000 , 
TRAVELLING_EX' at line 1 

代碼:

 Class.forName("com.mysql.jdbc.Driver"); 
     Connection con = DriverManager.getConnection(DB_URL,"root","root"); 
     System.out.println("Remote DB connection established"); 
     PreparedStatement statement=con.prepareStatement("UPDATE TBL_MONTHLY_EXPENSES_DETAILS " + 
       "SET AVG_COST = "+AVG_COST+" ," + 
        " RWDS_INCENT = "+RWDS_INCENT +" ,"+ 
        " OTH_EXPENSES = "+OTH_EXPENSES+" ,"+ 
        " TRAVELLING_EXPENSES = "+TRAVELLING_EXPENSES+" ,"+ 
        " CLIENT_VISITS = "+CLIENT_VISITS+" ,"+ 
        " REV_RECD = "+REV_RECD+" " 
       +" WHERE PJT_CODE = '"+PJT_CODE 
       +"' AND PJT_MONTH = '"+PJT_MONTH 
       +"' AND PJT_YEAR = '"+PJT_YEAR+"' " 
       ); 
     statement.executeUpdate(); 

回答

0

TRAVELLING_EXPENSES可能有問題。檢查您嘗試更新的值。

+0

另外我想知道在mysql數據庫中插入相同值的查詢。 – Numaish

+0

查看這裏的文檔:http://dev.mysql.com/doc/refman/5.6/en/insert.html – Szymon

+0

我想在MySQL中插入相同的數據與上面相同(更新查詢)。什麼是修改更新查詢? – Numaish