zoukankan      html  css  js  c++  java
  • sql语句的编写

    不同的sql语句的sql配置文件的编写

    1.查询的时候做模糊查询。

    <select id="selectMany" parameterType="java.lang.String" resultType="com.gxa.bj.model.Cate">

            Select * From cate Where name like '%${value}%'

      </select>

    2.普通的插入语句:

    <insert id="insertCate" parameterType="com.gxa.bj.model.Cate">

            Insert into Cate(name,description) values(#{name},#{description})

      </insert>

    3.插入语句之后,获取刚插入的主键的数据:

    <insert id="insertCate" parameterType="com.gxa.bj.model.Cate">

            <selectKey keyProperty="id" resultType="java.lang.Integer" order="AFTER">

               select last_insert_id()

            </selectKey>

            Insert into Cate(name,description) values(#{name},#{description})

         </insert>

    如果是mysql的uuid。那么sql的编写为: 

    <insert id="insertCate" parameterType="com.gxa.bj.model.Cate">

       <selectKey keyProperty="id" resultType="java.lang.Integer" order=“BEFORE">

            select uuid()

       </selectKey>

       insert into cate(id,name,description)values(#{id},#{name},#{description})

    </insert>

    如果是oracle的序列,那么sql的编写为:

    <insert id="insertCate" parameterType="com.gxa.bj.model.Cate">

       <selectKey keyProperty="id" resultType="java.lang.Integer" order=“BEFORE">

            select 序列名.nextval()

       </selectKey>

       insert into cate(id,name,description)values(#{id},#{name},#{description})

    </insert>

    更新的sql语句:

    <update id="updateCate" parameterType="com.gxa.bj.model.Cate">

       update cate set name=#{name},description=#{description} where id=#{id}

    </update>

    删除语句:

    <delete id="deleteCate" parameterType="java.lang.Integer">

       delete from cate from id=#{id}

    </delete>

  • 相关阅读:
    python字典及其内置函数详解
    python函数语法学习
    python切片、迭代、生成器、列表生成式等高级特性学习
    Python入门及安装
    node中的加密模块 crypto
    Nodejs+MongoDB+Bootstrap+esj搭建的个人简易博客
    JavaScript的深拷贝和浅拷贝总结
    redux 学习总结
    简述redux(1)
    通信数据转发程序:代理、网关、隧道
  • 原文地址:https://www.cnblogs.com/myname/p/5694105.html
Copyright © 2011-2022 走看看