2

我有两张桌子

 t1
        id  |  value
        1   |   -
        2   |   -
 t2
       parent_id  |  p_value
        1         |   254
        2         |   124

我想将列p_value从 t2 复制到 t1 中parent_id = id

4

3 回答 3

6
update t1, t2 set t1.value = t2.p_value where t1.id=t2.parent_id
于 2013-10-24T10:08:34.060 回答
1

尝试这个:

   Update t1, t2 set t1.value = t2.p_value where t1.id = t2.parent_id;
于 2013-10-24T10:10:26.373 回答
0

尝试这个

update t1 join t2 on t2.parent_id= t1.id set t1.value = t2.p_value
于 2013-10-24T10:09:49.500 回答