Home » RDBMS Server » Server Administration » sql
sql [message #371802] Thu, 07 December 2000 23:23 Go to next message
sujathaThogachedu
Messages: 3
Registered: December 2000
Junior Member
I have a simple Employee table that contains three fields: Emp ID, Last Name and First Name. The table’s primary key is Emp ID
Sample Employee Table:
EMP_ID LAST_NAME FIRST_NAME
1 Smith Janet
2 Jones Jim
3 Johnson Mike
4 Carlos Frank
5 Brown Jerry

Also, I have a simple Family_Member table that contains: Member ID, Emp ID, Last Name, First Name, Relationship. The table’s primary key is Member ID. This table contains the name of an employee’s family members, if any. If the employee has no family members, there is no entry in this table
Sample Family Member Table:
MEMBER_ID EMP_ID LAST_NAME FIRST_NAME RELATIONSHIP
1 1 Smith Mike Spouse
2 1 Smith Jennifer Daughter
3 4 Carlos Maria Spouse
4 4 Carlos Michael Son
5 4 Carlos Sonya Daughter
6 5 Griggs Jane Spouse
7 5 Griggs Mary Daughter

How to write insert c to cjruhange the last name of the spouse for Employee ID 5 from ‘Griggs’ to ‘Brown’.
Re: sql [message #371805 is a reply to message #371802] Fri, 08 December 2000 07:20 Go to previous message
Babu Paul
Messages: 38
Registered: November 2000
Member
Hi,
The simplest way of doing it would be to update family_member table with the last_name and first_name values from Employee table.

ie. UPDATE family_member a
SET (last_name, first_name) = (select
last_name,first_name from employee where
emp_id = a.emp_id) ;

to ensure that the names are concurrent with your Employee table.

Good Luck!
Babu.
Previous Topic: adding duplicate records in plsql procedure
Next Topic: Oracle keeps giving back cached results...not new.....help!!!
Goto Forum:
  


Current Time: Thu May 02 02:21:27 CDT 2024