0

I have a table employee1 and employee2 where I would like to insert data from one table to another using select based on a condition such as

INSERT INTO EMPNO, EMPNAME, EMPAGE, EMPSALARY, EMPDESIGNATION SELECT EMPNO, EMPNAME, 0, '', EMPDESIGNATION WHERE EMPID=25

This is what I want to achieve as there are some values which i don't want to supply because they are default or for some other reason but this is not allowed.

Can you tell me how can I achieve this

2 Answers 2

2
INSERT INTO employee2
           (EMPNO, EMPNAME, EMPAGE, EMPSALARY, EMPDESIGNATION)
     SELECT EMPNO, EMPNAME, 0, '', EMPDESIGNATION
       FROM employee1
      WHERE EMPID=25;

You can specify the columns you want to provide values for, and then provide values for only those columns.

Sign up to request clarification or add additional context in comments.

Comments

0
insert INTO employee2 (EMPNO)
SELECT EMPNO from employee1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.