【SQL】临时表解决小表跨库JOIN

╄→гoц情女王★ 提交于 2020-01-14 00:59:44
-- SQL实现
select 10.00 as amount,'X031' as store_code 
union 
select 20.00 as amount,'D033' as store_code



-- MyBatis实现
select
        sd.daily_init_target_money  / tmp.reality_money as targetImplRate,
        tmp.reality_money  as salesAmount,
        sd.store_code
        from store_daily_sales_analyze sd
        join (
                <foreach collection="storeTargetDtoListList" item="storeTargetDtoListItem" 	  	index="index" separator="union">
                    select 
                    #{storeTargetDtoListItem.storeCode} as store_code,
                    #{storeTargetDtoListItem.salesAmount} as reality_money
                </foreach>
        )tmp on tmp.store_code = sd.store_code
        <where>
            <include refid="query_whereConditions"/>
        </where>
 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!