Home » SQL & PL/SQL » SQL & PL/SQL » regarding update statement (oracle 9i)
regarding update statement [message #329686] Thu, 26 June 2008 04:10 Go to next message
msafana
Messages: 31
Registered: July 2007
Member
hi all,
please help me to write this query.

First table Emp with columns emp_id,salary,dept_id
Emp
Emp_id salary dept_id
101 1000
102 2000
103 5000
104 6000

Second table Dept with column dept_id,department,emp_id

Dept
dept_id department emp_id
10 Account 101
30 Quality 102
50 Account 103
60 Quality 104

I want to insert the dept_id values from second table i.e.,dept by using emp_id values.The query using update statement.please help me in writing the query.
Thanks in advance
Re: regarding update statement [message #329687 is a reply to message #329686] Thu, 26 June 2008 04:11 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
Please read the forum guidelines and post what you have tried so far to solve the problem.

Regards

Raj
Re: regarding update statement [message #329706 is a reply to message #329686] Thu, 26 June 2008 05:13 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
First, please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter).
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Then it is a simple update statement.

Regards
Michel
Re: regarding update statement [message #329709 is a reply to message #329686] Thu, 26 June 2008 05:23 Go to previous messageGo to next message
mshrkshl
Messages: 247
Registered: September 2006
Location: New Delhi
Senior Member
update emp a set a.deptid =(select dept_id from dept b where a.emp_id=b.emp_id);


regards,
kaushal
Re: regarding update statement [message #329718 is a reply to message #329709] Thu, 26 June 2008 05:41 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Don't put solution only hint or clue as requested in OraFAQ Forum Guide, "Responding to Posts" section:
Quote:
When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.


Regards
Michel
Previous Topic: regarding check constraints
Next Topic: query
Goto Forum:
  


Current Time: Sat Dec 10 08:57:31 CST 2016

Total time taken to generate the page: 0.26191 seconds