Mybaits if the data in the database is modified, if there is no new

Source: Internet
Author: User

Sometimes you get the need to modify the data in the database if there is one.

Before receiving this demand, the first idea is: first to the data query there is no this data, some words go to modify, no words to go new.

Then we found this solution: post it and share it.

Merge into Table P
using (SELECT ' ${column} ' columnfrom dual) d

On (d.column= p.column)

When the matched then UPDATE statement

When isn't matched then insert statement

This means that the database is queried for this data based on a unique identification field, and if the match is done, the update is done, and if it does not match, the new action is added.

Mybaits if the data in the database is modified, if there is no new

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.