Skip to content

Ability to perform merge update #85

Open
@reenimathew

Description

@reenimathew

Is it possible to perform update by joining with another table? I don't see such a capability.
Can someone help with this? I don't want to do sub query as I need to update multiple columns from other table.

UPDATE Products
SET end_date = other.end_date
FROM Products me
JOIN #updates other
ON (me.id = other.id)

Activity

jeffgbutler

jeffgbutler commented on May 17, 2019

@jeffgbutler
Member

This syntax isn't in the library now. You could easily code this statement by hand and add it to a mapper.

DaZuiZui

DaZuiZui commented on May 15, 2023

@DaZuiZui

hope i can help,my idea is to use JOIn to join other tables,and defube ub tge XML mapping file how to execute the sql statement.

<update id="debugFuction" parameterType="UrParameterType">
  UPDATE tmptable1 t1
  JOIN tmptable2 t2 ON (t1.id = t2.id)
  SET t1.testdate = t2.testdate
</update>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jeffgbutler@reenimathew@DaZuiZui

        Issue actions

          Ability to perform merge update · Issue #85 · mybatis/mybatis-dynamic-sql