gpt4 book ai didi

Java JPQL : add an int value to the already existing one in Database

转载 作者:行者123 更新时间:2023-12-02 04:19:48 24 4
gpt4 key购买 nike

我有一个表,其中有一列保存 int 值,我需要知道如何编写 JPQL 查询,该查询不是覆盖现有值,而是将新值添加到现有值并保留总和。这是设置值的 JPQL。

UPDATE Transaction t SET t.amount = :amount WHERE t.id = :id

最佳答案

就像 SQL 中一样:

UPDATE Transaction t SET t.amount = t.amount + 1 WHERE t.id = :id

关于Java JPQL : add an int value to the already existing one in Database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32920948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com