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>

  • 相关阅读:
    数据仓库的一些理解(转)
    常见ETL工具一览,你知多少?
    dhcpv6开源软件配置
    svn
    js原型模式
    combo扩展:禁止手工改变输入框的值
    SQLite错误总结 error code 19: constraint failed
    ntp源码解读(一)
    ntp-keygen.c
    6.2.2认证
  • 原文地址:https://www.cnblogs.com/myname/p/5694105.html
Copyright © 2011-2022 走看看