Reputation: 51
i have table A
mem_id | temp_id | version
--------------------------
1 | 1008 | 1
2 | 1009 | 1
3 | 1010 | 1
4 | 1021 | 1
and table B
temp_id | base id | desc
--------------------------
1008 | 720 | GP
1009 | 720 | GP
1010 | 720 | GP
1021 | 720 | GP
I want to do an update statement that will update the temp_id
for all mem_id
in table A to only temp_id = 1008
.
update table a
set a.temp_id = (minimum of temp_id in table b)
where a.temp_id in (select temp_id in table b where b.tempid (min)
i want it to check for the minimum value in table b_temp_id
and then set all values in table A_temp_id
to be the same.
Upvotes: 1
Views: 51
Reputation: 65105
You can directly update by
update tableA A
set temp_id = (select min(temp_id) from tableB)
for the whole data set without any restriction
Upvotes: 1