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 SaxenaTOP 100Posted Jul 18, 2015, 3:32 AM EDT
Thanks 2 All
Rahul Kumar SaxenaTOP 100Posted Jul 11, 2015, 1:38 AM EDT
Thanks Santhakumar Munuswamy
Santhakumar MunuswamyPosted Jul 10, 2015, 10:58 PM EDT
Nice article! Thanks for sharing
Rahul Kumar SaxenaTOP 100Posted Jul 9, 2015, 5:49 AM EDT
Thanks Rakesh Kalluri
Rahul Kumar SaxenaTOP 100Posted Jul 9, 2015, 5:49 AM EDT
Thanks Pankaj Kumar Choudhary
Rakesh KalluriPosted Jul 9, 2015, 4:19 AM EDT
Nice post sir.
Pankaj Kumar ChoudharyTOP 100Posted Jul 9, 2015, 3:56 AM EDT
Nice Article Sir.......
Rahul Kumar SaxenaTOP 100Posted Jul 9, 2015, 2:47 AM EDT
Thanks Upendra Pratap Shahi
Rahul Kumar SaxenaTOP 100Posted Jul 9, 2015, 2:47 AM EDT
Thanks Sibeesh Venu
Upendra Pratap ShahiPosted Jul 9, 2015, 2:44 AM EDT
Nice article Rahul Saxena Sir, thanks for sharing.....
Sibeesh VenuTOP 100Posted Jul 9, 2015, 2:41 AM EDT
Good One! Thanks for sharing