我有两张桌子
t1
id | value
1 | -
2 | -
t2
parent_id | p_value
1 | 254
2 | 124
我想将列p_value
从t2复制到t1,其中parent_id = id
答案 0 :(得分:5)
update t1, t2 set t1.value = t2.p_value where t1.id=t2.parent_id
答案 1 :(得分:1)
试试这个:
Update t1, t2 set t1.value = t2.p_value where t1.id = t2.parent_id;
答案 2 :(得分:0)
试试这个
update t1 join t2 on t2.parent_id= t1.id set t1.value = t2.p_value