首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > PowerDesigner >

Mysql的话语:用select来update

2012-09-08 
Mysql的语句:用select来update从 t2表中 select 出来数据 ,更新 t1 表里面的数据。 update t1 set t1.count

Mysql的语句:用select来update

从 t2表中 select 出来数据 ,更新 t1 表里面的数据。

update t1

set

t1.count = (

select max(num) from t2 where t1.id = t2.pid group by pid

)?

update t1 set t1.count = (select max(num) from t2 where t1.id = t2.pid group by pid )?

在用来更新一些 统计数据方面很有用。

还有

insert into with select insert into myDestTable (userid, name, value, othercolumns) select us.userid, us.name,'myvaluefromcode', othercolumns from users us where us.name = 'mynamefromcode'

?

来自:Mysql的语句:用select来update

?

热点排行