I have 3 tables in my data base
I need to take each id from table1 and need to look in table2 if it is present then do nothing other wise for that Id I need to look into table3 if i am able to find it then fetch the phone number and along with the details from table 1 insert it into table2 .How to do this in oracle ?
CodePudding user response:
You can try this:
INSERT INTO table_2
SELECT table_1.id, table_1.name, table_1.gender, table_1.age, table_3.phone_num
FROM table_1
INNER JOIN table_3 ON table_1.id = table_3.id
WHERE table_1.id NOT IN (SELECT id FROM table_2);