<!--根据poi_info表的id和city_id更新flag_hinterland_flows的poi_id和city_id-->
<select id="selectPoiAndCityId" parameterType="java.lang.Long" resultType="com.wormpex.gs.stat.service.dao.entity.baseinfo.PoiAndCityId">
select n.id as poiId,n.city_id as cityId,n.code as code from poi_info n inner join flag_hinterland_flows m
/*1用inner join,只返回满足匹配条件的数据,减少数据库io次数*/
on m.flag_code=n.code
<where>
<if test="id != null">
n.id<![CDATA[<=]]>#{id,jdbcType=BIGINT}
</if>
</where>
</select>
<update id="updatePoiAndCityId" parameterType="com.wormpex.gs.stat.service.dao.entity.baseinfo.PoiAndCityId" >
update flag_hinterland_flows
<set>
poi_id=#{poiId,jdbcType=BIGINT},
<if test="cityId != null">
city_id=#{cityId,jdbcType=BIGINT},
</if>
</set> /*2set标签可以自动忽略if标签中多余的逗号,但是,对于if标签里面再嵌套一层if的时候,set标签就不能自动忽略了*/
where /*3where放到set标签外边*/
flag_code=#{code,jdbcType=VARCHAR}
</update>