Home > Net >  How we can update table A column by table B column value using liquibase yml script
How we can update table A column by table B column value using liquibase yml script

Time:10-19

I want to update table A's name column with Table B's name column value where table B's id is present in table A. I am trying this using the liquibase yml script but its not working.

databaseChangeLog:
- changeSet:  
    id:  update-name  
    author:  xyz  
    changes:  
    -  update:  
        columns:  
        -  column:  
            name:  name  
            value: A.name = B.name  
        tableName: A
        where:  A.a_id = B.id

CodePudding user response:

Finally, I found a way to write a Liquibase script for this, here I am posting it, might be it would be helpful for someone. I have just called the native query for updating the data from table B.name to A.name .

databaseChangeLog:
- changeSet:  
    id: update-name
    author: xyz  
    changes:  
      - sql:
          update A set name = b.name from B b where id = b.id;
  • Related