Solved

update set column values in oracle

Posted on 2016-09-30
3
76 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

751 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