Home » SQL & PL/SQL » SQL & PL/SQL » how to write this update query?
how to write this update query? [message #602110] Fri, 29 November 2013 10:07 Go to next message
jalal-rasooly
Messages: 11
Registered: November 2013
Junior Member
assume i have 3 table

**A**************B******************C
-----******-------------*****----------------
pk_a********pk_b***Fk_a******id***fk_b***fk_a
.....*******....***....******..***....***....
*A1**********B1*****A3*******1*****B1
*A2**********B2**************2
*A3**********B3*****A2*******3*****B2
*A4**********B4*****A1*******4*****B1
*****************************5*****B3

fk_a in table B (B.fk_a) and table C (C.fk_a) is foreign key yo table A
fk_b in table C (C.fk_b) is foreign key to table B

now i want for every row in table B that pk_b has a related fk_a (both be in a same row), for any rows in table C that have the same pk_b, put the related fk_a in the same row on column pk_a.

i mean after update table C should look like this:

*********C***********
---------------------
id******pk_b*****pk_a
..******....*****....
*1*******B1*******A3
*2
*3*******B2
*4*******B1*******A3
*5*******B3*******A2

Now I Want TO Know How To Wright This Update Query in oracle?

[Updated on: Fri, 29 November 2013 10:22]

Report message to a moderator

Re: how to write this update query? [message #602112 is a reply to message #602110] Fri, 29 November 2013 10:13 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Please post CREATE TABLE statements for each of the 3 tables.
Please post INSERT statements to populate tables with the sample data.

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/

Re: how to write this update query? [message #602114 is a reply to message #602112] Fri, 29 November 2013 10:31 Go to previous messageGo to next message
jalal-rasooly
Messages: 11
Registered: November 2013
Junior Member
i want to apply your suggestions but i cant edit my post!
Re: how to write this update query? [message #602134 is a reply to message #602114] Fri, 29 November 2013 15:41 Go to previous message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That's true, but nothing prevents you from doing that in a brand new message posted at the bottom of this thread.
Previous Topic: Run same procedure parallely in different sessions with diff parameter value
Next Topic: Query to PIVOT
Goto Forum:
  


Current Time: Fri Mar 29 06:39:37 CDT 2024