Skip to content
Advertisement

Migrate data from one table to the other

I have two tables and I have to transfer data from one to the other.

Table 1: employees

Table 2 emp_address

I need to migrate data from one to the other.

So I have only 2 conditions while inserting:

  1. I cannot insert the address which has already been inserted into the emp_address for that employee.

  2. The is_permanent flag is set to true if no address has been inserted for the employee (i.e. if no single entry is present for the employee set is as true else false)

I cannot seem to get my head around how to I do this.

Advertisement

Answer

Use not exists :

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