Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update subselect

Status
Not open for further replies.

gdg1976

Programmer
Sep 1, 2021
14
0
0
IT
hi all,

input
[pre]TAB1
COL1 COL2 COL3 COL4
AAA 1 A1 1
AAA 2 A2 1
AAA 3 A3 0
BBB 9 A1 1
BBB 99 A2 1
BBB 999 A3 0[/pre]

How can i obtain the follow output with an update ?


output
[pre]TAB1
COL1 COL2 COL3 COL4
AAA 9 A1 1
AAA 99 A2 1
AAA 3 A3 0
BBB 9 A1 1
BBB 99 A2 1
BBB 999 A3 0[/pre]


Is this update enought ?

update tab1 a set a.col2 =
(select b.col2 from tab1 b
where b.col3 = a.col3
and b.col1 = 'BBB')
where a.col4 = 1
and a.col1 = 'AAA'

thanks to all in advance.
bye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top