Search code examples
sqlamazon-redshiftaginity

Get Rows which are updated in new table compared to old table -SQL


I have a table as

id  Description Tag
1       ABC         Tag1
2       DEF         Tag2
3       ABC         Tag1
4       ABC         Tag1
5       GHI         Tag3
6       DEF         Tag2

and whenever i need to make multiple changes I will create a new table and change the values (tag column). I need a query to get the rows where the tag column has a different value compared to old table.


Solution

  • I have found the answer to this

    select a.id, a.description, a.tag, b.tag
    from tableA a, tableB b
    where a.tag<>b.tag
    and a.id=b.id