Skip to content
Advertisement

Add a new column from compare result

I need add a new column (status) on my main table (Table 1) on my bd Postgres, to do this , I need to compare two columns from table 1 on table 2 , if the two columns exist , I need to copy the status from table 2 to the new column on table 1 , if not exist , e need to fill the status column with ‘New’. Do youw know if it´s possible ? how ?

Table 1

Table 2

Table 1 with a new status column

Thanks

Advertisement

Answer

You are describing a LEFT join of Table1 to Table2:

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