多表联合操作
来源:互联网 发布:64位sql安装提示错误 编辑:程序博客网 时间:2024/06/10 09:25
有如下三张表:
fund_forsale
fund_gen_info
fund_asset_conf
表fund_forsale更新方式为:选取表fund_asset_conf中对应最新(enddate倒序)基金的asset_conf字段
有以下两种方法
insert into fund_forsale (fundCode,market_value)( select fund_code as fundCode,asset_nav as market_valuefrom (select b.fund_code,conf.* from fund_asset_conf conf,fund_gen_info bwhere conf.fund_id=b.fund_id and b.fund_code in(select fundCode from fund_forsale) order by enddate desc ) agroup by fund_code )on duplicate key update market_value=values(market_value);
运行时间6.97s
update fund_forsale as c inner join (select fund_code, asset_nav from fund_gen_info natural join (select fund_id, asset_nav from fund_asset_conf natural join (select fund_id, max(enddate) as enddate from fund_asset_conf group by fund_id) as t1) as t2) b on b.fund_code=c.fundCode set c.market_value=b.asset_nav;
运行时间0.15s
0 0
- 多表联合操作
- 多表操作、外键、视图、多表联合
- 多表联合查询
- 多表联合查询
- 多表联合更新
- 联合多表查询
- SQL 多表联合
- Yii2 多表联合
- 多表联合查询
- 多表联合查询
- hibernate操作联合主键
- jeecg联合查询操作?
- MYSQL多表联合更新
- oracle 多表联合更新
- Oracle多表联合更新
- SQL 多表联合查询
- sql 多表联合更新
- Oracle多表联合查询
- SDAU 搜索专题 06 Line belt
- NFS
- 1006. Sign In and Sign Out (25)
- poj1017(贪心)
- 2016-04-06
- 多表联合操作
- LeetCode--max-points-on-a-line
- KMP字符串匹配算法(二)—KMP要点和证明
- 整数之循环节点求和
- Django Project在apache部署配置信息
- jQuery 效果(2)——停止动画
- adb shell am start权限问题解决
- LeetCode *** 169. Majority Element
- 将Unicode编码值转换为Unicode字符串