Here is my first table from which I will read the Distinct Manager column value. It is shown below.
Now see all the records in my Employee Table.
Figure 1: Employee Table
Now select Distinct Manager from this table as in the following:
Figure 2: Select a name
Here is my second table in which I will insert the Manager name:
Figure 3: Insert a name
Now write your SQL statement to achieve our desired functionality:
- INSERT INTO Manager(ManagerName)
- SELECT DISTINCT ManagerName
- FROM Employee
- WHERE ManagerName NOT IN(SELECT ManagerName FROM Manager);

Figure 4: Execute Query
Now select records from the manager table:

Figure 5: Select Record
If you hit this Query again then it will not insert any duplicate records into the Manager records and if a new manager name is to be inserted into the Employee table then it will insert that newly added manager name:

Figure 6: Hit the Query

Rahul Kumar SaxenaPosted Jul 18, 2015, 7:32 AM
Thanks 2 All
Rahul Kumar SaxenaPosted Jul 11, 2015, 5:38 AM
Thanks Santhakumar Munuswamy
Santhakumar MunuswamyPosted Jul 11, 2015, 2:58 AM
Nice article! Thanks for sharing
Rahul Kumar SaxenaPosted Jul 9, 2015, 9:49 AM
Thanks Rakesh Kalluri
Rahul Kumar SaxenaPosted Jul 9, 2015, 9:49 AM
Thanks Pankaj Kumar Choudhary
Rakesh KalluriPosted Jul 9, 2015, 8:19 AM
Nice post sir.
Pankaj Kumar ChoudharyPosted Jul 9, 2015, 7:56 AM
Nice Article Sir.......
Rahul Kumar SaxenaPosted Jul 9, 2015, 6:47 AM
Thanks Upendra Pratap Shahi
Rahul Kumar SaxenaPosted Jul 9, 2015, 6:47 AM
Thanks Sibeesh Venu
Upendra Pratap ShahiPosted Jul 9, 2015, 6:44 AM
Nice article Rahul Saxena Sir, thanks for sharing.....
Sibeesh VenuPosted Jul 9, 2015, 6:41 AM
Good One! Thanks for sharing