表未更新。我使用相同的语法来更新其他表,但是这个表不起作用

时间:2016-07-21 19:40:03

标签: java mysql sql

此sql查询未更新数据库,而是返回错误。有什么建议吗?

PreparedStatement ps10 = con.prepareStatement("UPDATE payroll_system.payslip SET hours_worked = (SELECT SUM(Hours) FROM payroll_system.monthly_timesheet WHERE employeeID=?) WHERE employeeID=?");
                    ps10.setString(1, employee_id);
                    ps10.setString(2, employee_id);
                    ps10.executeUpdate();

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

试试这个:

UPDATE payroll_system.payslip as t1 
    SET hours_worked = (SELECT SUM(Hours) FROM payroll_system.monthly_timesheet WHERE employeeID=t1.employeeID) 
    WHERE employeeID=?