Solved

update set column values in oracle

Posted on 2016-09-30
3
56 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 47

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

776 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