Solved

update set column values in oracle

Posted on 2016-09-30
3
48 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 46

Expert Comment

by:Vitor Montalvão
ID: 41823643
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
ID: 41823677
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
ID: 41823716
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
automatic email alert 1 42
Maintaining Oracle Managed Accounts 2 30
sql query 9 38
database upgrade 8 41
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.

920 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

16 Experts available now in Live!

Get 1:1 Help Now