Solved

PL/SQL update with joining other tables

Posted on 2010-08-18
2
359 Views
Last Modified: 2013-12-19
I am trying to do a simple update statement in PL/SQL, Oracle 9i.

Table A
col1    col2     col3
1         1          Y
2         1          N
3         1          

Table B
col1    col2    col3
1         1         Y
2         1         Y
3         1         Y

All I need to do is the update Table B col3  the same as in Table A col3, if Table A col3 is null, then update as N.

I know oracle doesn't have the update from like SQL Server.  This makes it very difficult for me.  Please help.  Thanks.
0
Comment
Question by:cmleung2
2 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 33470278
update
 (select b.col1, b.col2, a.col3 as col3a, b.col3 as col3b
  from tableb b left join tablea a on a.col1=b.col1 and a.col2=b.col2) t
set
 t.col3b=nvl(t.col3a, 'N')
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
ID: 33470313
update tableB b
set col3 = nvl((select col3 from tableA a where a.col1=b.col1 and a.col2=b.col2),'N')
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Via a live example, show how to take different types of Oracle backups using RMAN.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

786 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