Solved

update set column values in oracle

Posted on 2016-09-30
3
42 Views
Last Modified: 2016-09-30
I have two tables and would like to update the values of a column in first table

Table 1
--------------------------------------------
userid            
-------------------------------------------
allen

james

Table 2

------------------------------------------------
user ID                Lan ID
------------------------------------------------

allen                      1

james                  2

here what I would like to see the table1

userid
----------

1

2
0
Comment
Question by:easy_life
3 Comments
 
LVL 45

Expert Comment

by:Vitor Montalvão
Comment Utility
UPDATE T1
SET T1.UserID = T2.LanID
FROM Table1 T1
    INNER JOIN Table2 T2 ON T1.UserID = T2.UserID

Open in new window

0
 
LVL 4

Accepted Solution

by:
Abhimanyu Suri earned 500 total points
Comment Utility
SQL> select * from asuri.test_20160928;

NAME
----------
ALLEN
JAMES

SQL> select * from asuri.test_20160928_2;

NAME           USERID
---------- ----------
ALLEN               1
JAMES               2


SQL> update asuri.test_20160928 g set g.name = ( select USERID from asuri.test_20160928_2 b where b.name=g.name);

2 rows updated.

SQL> select * from asuri.test_20160928;

NAME
----------
1
2

SQL> select * from asuri.test_20160928_2;

NAME           USERID
---------- ----------
ALLEN               1
JAMES               2
0
 

Author Closing Comment

by:easy_life
Comment Utility
Thanks for the help
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now