Chinaunix

标题: 请教个update语句 [打印本页]

作者: lmwzmf    时间: 2010-10-12 09:40
标题: 请教个update语句
有两张表,tb1和tb2,信息如下:
tb1
col1  col2  col3  col4
23    34     54   
25    tgf     hgt   
24    tf       yh      
27    yh     yh
……     

tb2
bol1   bol2    bol3
23       hy      ju
24        jy      ki
25       hy     ju
27       kg      lj
……

需要更新tb1的col4列数据为tb2的bol3列,关联关系为tb1.col1=tb2.bol1   ,不知道用update怎么实现,哪位高手帮忙解答下,谢谢!
作者: yunzhongyue    时间: 2010-10-12 13:58
update tb1 set col4=(select bol3 from tb2 where tb1.col1=tb2.bol1)
作者: meditatorx    时间: 2010-10-12 14:29
update tb1 set col4=(select bol3 from tb2 where tb1.col1=tb2.bol1)
yunzhongyue 发表于 2010-10-12 13:58



    引用
作者: lmwzmf    时间: 2010-10-12 15:25
回复 2# yunzhongyue


    谢谢!!:wink:




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2