Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

update set column values in oracle

Posted on 2016-09-30
3
Medium Priority
?
87 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 52

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 5

Accepted Solution

by:
Abhimanyu Suri earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

927 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