zoukankan      html  css  js  c++  java
  • Mybatis 采坑记录--set标签的使用

     <!--根据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>
  • 相关阅读:
    笔记。------数组
    图片与文字的对齐方式
    clear:both;和overflow:hidden;的应用理解。
    淘宝首页
    错误:编码GBK的不可映射字符
    Java基础之反射
    (一)Servlet简介
    Windows10快捷键
    (二)Maven的安装与环境配置
    (一)Maven简介
  • 原文地址:https://www.cnblogs.com/Allen-win/p/8051561.html
Copyright © 2011-2022 走看看