mybatis-xml中寫sql語句

1.時間參數比較
2.mybatis中if–else if
沒有if–else

    <select id="getMyAbsentList" resultType="com.dayou.cloud.sys.entity.BscAbsent">
        select a.* from bsc_absent a,map_student_class b 
        where a.partyid = b.studentid and b.classid = #{classid} and a.state='nor'
        <if test="type!=null and type!=''">
        and a.type=#{type}
        </if>
        <if test="starttime!=null and starttime!=''">
            and a.starttime&gt;=#{starttime}
        </if>

        <choose>
            <when test="endtime!=null and endtime!=''">
                and a.endtime&lt;=#{endtime}
            </when>
            <otherwise>
                and a.endtime&gt;=now()
            </otherwise>
        </choose>   

    </select>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章