Home » SQL & PL/SQL » SQL & PL/SQL » Update value from other table's value
Update value from other table's value [message #218812] Sat, 10 February 2007 11:48 Go to next message
pakcikkantin
Messages: 4
Registered: February 2007
Junior Member
tableA
ID STATUS
1 PENDING 
2 PENDING

tableB
ID STATUS
1 OK
2 OK


How to update STATUS of tableA with the STATUS value of tableB

Tq
Re: Update value from other table's value [message #218826 is a reply to message #218812] Sat, 10 February 2007 19:50 Go to previous messageGo to next message
BlackSwan
Messages: 25042
Registered: January 2009
Location: SoCal
Senior Member
>How to update STATUS of tableA with the STATUS value of tableB
By combining UPDATE tableA & SELECT STATUS FROM tableB while using an appropriate WHERE clause
Re: Update value from other table's value [message #218900 is a reply to message #218812] Sun, 11 February 2007 23:26 Go to previous messageGo to next message
tarmenel
Messages: 63
Registered: February 2007
Location: Israel
Member

Is there another coloumn you want to update or simply the update field of table A? Or are you trying to combine the two tables to get a result of the status? Sorry but I'm not sure what you are needing to do so if you give a bit more info may we could help.
Re: Update value from other table's value [message #218946 is a reply to message #218826] Mon, 12 February 2007 03:30 Go to previous messageGo to next message
prashas_d
Messages: 66
Registered: February 2007
Member
anacedent,

can you write some sample statement that has the combination of update and select statement?

If possible please consider the example from pakcikkantin.

Thanks,
prashas_d.
Re: Update value from other table's value [message #219022 is a reply to message #218812] Mon, 12 February 2007 10:46 Go to previous messageGo to next message
pselvam76
Messages: 12
Registered: February 2007
Junior Member
Hi

You can use the following syntax for updating

update tableA A
set status = (select status from tableB B where b.id = a.id)
where
exists
(
select 'X' from tableB B
where b.id = a.id
)

Thanks
Panneer Selvam
Re: Update value from other table's value [message #219097 is a reply to message #219022] Mon, 12 February 2007 23:00 Go to previous message
prashas_d
Messages: 66
Registered: February 2007
Member
pselvam76,

Thanks for your help.

I ran the sql statement given by you and it's doing the required job.

Thanks,
prashas_d.
Previous Topic: Charaterset Converstion to UTF8
Next Topic: Cursor Or Ref Cursor
Goto Forum:
  


Current Time: Tue Dec 06 16:18:11 CST 2016

Total time taken to generate the page: 0.10390 seconds