1

I have a table EMP that looks like this

EID || ENAME || ESAL || LOC
------------------------------------------------------------ 
1111 || David Rockwell || 50000 || - 
2222 || Michael Bubey || 33000 || - 
3333 || Samuel Lukas || 35000 || - 
5555 || Mike Pribley || 35000 || - 

I have another table DEPT that looks like this

DEPT_ID ||   DNAME  ||  LOCATION
-----------------------------------------------
1111          ||   ABC        ||    USA
2222         || DEF        || Japan
3333         || GHI         || UK
4444         || JKL         ||Brazil
5555         || LMO        || India

My aim is to insert the values of dept.LOCATION into emp.LOC

NOTE:

  1. The insertion should be such that the emp.loc=dept.LOCATION where dept.dept_id=emp_eid
  2. There are no constraints in any of the tables. (You are free to add in your solution)

RESULT

EID  ||     ENAME                    || ESAL   ||   LOC 
------------------------------------------------------------
1111 ||  David Rockwell  || 50000 ||      USA 
2222 || Michael Bubey   || 33000 ||   JAPAN 
3333 || Samuel Lukas      || 35000 ||     UK 
5555 || Mike Pribley         || 35000 ||      India 

Thank you for your support.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • This is a violation of database normalization principles. You shouldn't duplicate the location information in two tables, then you have to do extra work to keep them in sync all the time. – Barmar Oct 25 '19 at 16:11

0 Answers0