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>

  • 相关阅读:
    ALLTOALL在线格式转换
    navicat注册码(亲测可用)
    抓包工具Fiddler设置(IOS)
    第三方设备云接入小米IOT平台
    snowboy进行语音唤醒,编译snowboy文件
    微信公众号开发之调起拍照或从手机相册中选图接口
    开放API网关实践
    分布式服务限流实战,已经为你排好坑了
    注解@PostConstruct与@PreDestroy使用讲解
    [转]布隆过滤器过时了,未来属于布谷鸟过滤器?
  • 原文地址:https://www.cnblogs.com/myname/p/5694105.html
Copyright © 2011-2022 走看看