zoukankan      html  css  js  c++  java
  • mybatis的增删改查

    1.插入方法

    <insert id="insert">

            INSERT INTO bs_manage_drugin(

                id,

                <if test="drugId != null and drugId != ''">

                drugid,

                </if>

                <if test="spec != null and spec != ''">

                spec,

                </if>

                <if test="manufacturer != null and manufacturer != ''">

                manufacturer,

                </if>

                create_by,

                create_date,

                update_by,

                update_date,

                del_flag,

                remarks

            ) VALUES (

                #{id},

                <if test="drugId != null and drugId != ''">

                #{drugId},

                </if>

                <if test="spec != null and spec != ''">

                #{spec},

                </if>

                <if test="manufacturer != null and manufacturer != ''">

                #{manufacturer},

                </if>

                #{createBy.id},

                #{createDate},

                #{updateBy.id},

                #{updateDate},

                #{delFlag},

                #{remarks}

            )

        </insert>

    2.修改方法

        <update id="update">

        UPDATE   TABLE

           <trim prefix="set" suffixOverrides=",">   //在前面加上set  去掉最后的逗号!!!

           <if test="id!=null">

            id= #{id},

           </if>

          <if test"name!=null">

            name = #{name},

         </if>

         </trim>

    where id = #{id}     

    </update>

    3.删除 

    <delete id="delete">
    DELETE FROM bs_child_tip
    WHERE vaccid = #{vaccid} AND remindtype = #{remindtype} AND "LOCALCODE" = #{localCode}
    </delete>

    4.查询

    <select id="findListByVaccCode" resultType="ChildBaseinfo">
    SELECT
    <include refid="childBaseinfoColumns" />
    FROM bs_child_baseinfo a
    <where>
    <if test="localCode != null and localCode != ''">
    AND A."LOCALCODE" = #{localCode}
    </if>
    <if test="vaccCardCode!=null and vaccCardCode!=''">
    AND vaccCardCode = #{vaccCardCode}
    </if>

    <if test="propertiess != null and propertiess != ''">
            AND a.properties in <foreach collection="propertiess" item="item" index="index" open="(" separator="," close=")">#{item}</foreach>
    </if>

    </where>
    </select>
  • 相关阅读:
    如何学习go源码
    最近打仁王2
    如何在时间复杂度为O(n)空间复杂度为O(1)的情况下完成链表的逆置
    漏洞复现-shellshock-bash破壳
    漏洞复现-aria2-任意文件写入
    漏洞复现-apereo-cas-4.1-rce
    漏洞复现-cgi-httpoxy
    漏洞复现-weblogic_weak_password-getshell
    sqlserver2008安装教程
    mysql内一些可以延时注入的查询语句
  • 原文地址:https://www.cnblogs.com/banxian-yi/p/10636378.html
Copyright © 2011-2022 走看看