zoukankan      html  css  js  c++  java
  • mybatis中的mapxml的语法

    <select id="a" resultMap="map">
    select
    *
    from `table`
    where (po_type='1')
    and t2.dn_id in
    <foreach item="item" index="index" collection="si_dn_ids" open="(" separator="," close=")">
    #{item}
    </foreach>
    <choose>
    <when test="poNo != null and poNo !='' ">
    `po_no`=#{poNo}
    </when>
    <otherwise>
    <![CDATA[
    `create_time` >= #{startTime} and `create_time` < #{endTime}
    ]]>
    <if test="status != 0">
    and `status`=#{status}
    </if>
    <if test="pager != null">
    limit #{pager.start},#{pager.pageSize}
    </if>
    </otherwise>
    </choose>
    </select>

    其中,foreach元素的属性主要有 item,index,collection,open,separator,close。item表示集合中每一个元素进行迭代时的别名,即为list中的每个元素,可以是String等类型,也可以是bean(如果直接传的bean,需要拼接bean的某个属性的值,可以写为#{item.property} ),index指定一个名字,用于表示在迭代过程中,每次迭代到的位置,open表示该语句以什么开始,separator表示在每次进行迭代之间以什么符号作为分隔 符,close表示以什么结束。

    更多动态sql语法参见:http://blog.csdn.net/luqin1988/article/details/7831927

  • 相关阅读:
    Web后台框架 目录
    C++ 目录
    【花书笔记】线性代数
    【Python数据挖掘概念、方法与实践】
    【统计学习基础】2. Overview of Supervised Learning
    字节与16进制
    【西瓜书】线性模型
    MySQL入门经典
    【机器学习基石】感知机模型
    python:web应用程序
  • 原文地址:https://www.cnblogs.com/superJF/p/4994785.html
Copyright © 2011-2022 走看看