我有兩個表複製列值插入到另一匹配ID
t1
id | value
1 | -
2 | -
t2
parent_id | p_value
1 | 254
2 | 124
我想列p_value
從T2複製到T1,其中parent_id = id
我有兩個表複製列值插入到另一匹配ID
t1
id | value
1 | -
2 | -
t2
parent_id | p_value
1 | 254
2 | 124
我想列p_value
從T2複製到T1,其中parent_id = id
update t1, t2 set t1.value = t2.p_value where t1.id=t2.parent_id
試試這個
update t1 join t2 on t2.parent_id= t1.id set t1.value = t2.p_value
試試這個:
Update t1, t2 set t1.value = t2.p_value where t1.id = t2.parent_id;