mybatis动态sql可以操作sql查询到的数据吗?

发布于 2025-01-10 10:42:22 字数 375 浏览 3 评论 0原文

Mybatis可以用“if”和“foreach”来操作输入参数数据,但是在同一个Mybatis sql中刚刚查询的数据呢?

案例:

桌子 场地 1

从表中选择字段; 将得到 1

Mybatis 可以通过这种语句将字段更新为 2 吗? :

<update id="updateField"> 
    select field from table;
    <if test="field != 0 ">
        update table 
        set field = 2
        where field = 1;
    </if>
<update>

Mybatis can operate input parameters data with "if" and "foreach", but how about the data just queried within same Mybatis sql?

case:

table
field
1

select filed from table;
will get 1

Can Mybatis manage to update field to 2 with this kind of statement? :

<update id="updateField"> 
    select field from table;
    <if test="field != 0 ">
        update table 
        set field = 2
        where field = 1;
    </if>
<update>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文