mybits学习 mapper

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="EmpMapper">
<select id="findAll" resultType="com.cy.pojo.Emp">
    select * from emp
</select>
<update id="insert" >
    insert into emp value (null ,"蔡恒","程序猿",54564);
</update>
    <update id="update">
        update emp set name="哈哈哈",job="公务员" where id=9
    </update>
    <select id="findById" resultType="com.cy.pojo.Emp">
            select * from emp where id=#{id}
    </select>
    <update id="insertEmp" >
        insert into emp value (null,#{name },#{job},#{salary})
    </update>
    <select id="findEmp" resultType="com.cy.pojo.Emp">
        select * from emp
        <if test="name!=null">
            where name like #{name}
        </if>
    </select>
    <select id="selectBySal" resultType="com.tedu.pojo.Emp">
        select * from emp where 1=1 <!-- 防止后面的条件连接不上 -->
        <if test="minSal!=null">
            and sal>=#{minSal}
        </if>
        <if test="maxSal!=null">
            <!-- &lt; 表示<
                 &gt; 表示>
                 &le; 表示<=
                 &ge; 表示>= -->
            and sal<![CDATA[<=]]>#{maxSal}
        </if>
    </select>
</mapper>
posted @ 2022-11-14 21:38  竹石2020  阅读(20)  评论(0编辑  收藏  举报