Skip to content
Advertisement

How to only display current and valid data from 2 tables in sql

I have these two tables:

Table imp_source:

Table imp_update:

I need to write a query to have this result:

  • All values of imp_update
  • The values of imp_source when there is no update for seq column of a product/class combination.

Update 1:

As you can see, the row in imp_source is not in result

Because in imp_update the seq column of product/class combination is updated:

Advertisement

Answer

We can use a union approach here with the help of exists logic:

screen capture from demo link above

Demo

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement