如何更改具有已实现值的表中的值?

问题描述 投票:0回答:1

我有一个表,其中有13列。在这13列中,我需要用第11行中的更新值替换先前的值。

if (Integer.parseInt(res.getString("res_id")) == res_id) {
    if (Integer.parseInt(res.getString("rem_pay")) > 0) {
        String a = res.getString("rem_pay");
        System.out.println("You need to pay the remaining amount: " + a);
        System.out.println("How much you want to pay?");
        amount=scanner.nextDouble();
        String query1= "INSERT INTO reservations values()"; //Changing the old rem_pay with the new one which the variable amount
        amount=Double.parseDouble(res.getString("rem_pay"))-amount;

任何答案都将非常有帮助。

java mysql
1个回答
0
投票
像这样更新表:

amount = Double.parseDouble(res.getString("rem_pay"))-amount; String query1 = "UPDATE reservations SET amount=?"; PreapredStatement pStatement = connection.prepareStatement(query1); pStatement.setDouble(amount); pStatement.executeUpdate();

© www.soinside.com 2019 - 2024. All rights reserved.