当前位置: 首页 > wzjs >正文

国内购物网站排名济南全网推广

国内购物网站排名,济南全网推广,图片优化网站,网站服务器在哪里买好目录 一.基础操作 1.删除 2.新增 3.更新 4.查询 5.XML映射文件 二、动态SQL 1.<if> 2.<where> 3.<set> 4.<foreach> 5.<sql> 6.<include> 一.基础操作 1.删除 参数占位符&#xff1a; 注意&#xff1a; #{...}相比于${...}…

目录

一.基础操作

1.删除

2.新增

3.更新

4.查询

5.XML映射文件

二、动态SQL

1.<if>

2.<where>

3.<set>

4.<foreach>

5.<sql>

6.<include>


一.基础操作

1.删除

参数占位符:

注意: 

#{...}相比于${...}具有性能高、防止SQL注入的优势

2.新增

3.更新

4.查询

普通查询:

条件查询:

注意:#{...}不能放在' '当中,使用${..,},会发生SQL注入,解决办法是使用contact()函数

数据封装: 

5.XML映射文件

实例:

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--namespace为Mapper接口的全限定名-->
<mapper namespace="com.itheima.springbootmybatisquickstart.mapper.EmpMapper"><!--id为函数名,resultType为返回的对象的全限定名--><select id="IndistinctSelect" resultType="com.itheima.springbootmybatisquickstart.pojo.Emp"><!--执行的SQL语句-->select id, username, password, name, gender, image, job, entrydate, dept_id deptId, create_time createTime, update_time updateTime from emp where name like concat('%',#{name},'%') and gender=#{gender} and entrydate between #{begin} and #{end}</select>
</mapper>

二、动态SQL

1.<if>

用于判断条件是否成立。使用test属性进行条件判断,如果条件为true,则拼接SQL

 <!--执行的SQL语句-->select id, username, password, name, gender, image, job, entrydate, dept_id deptId, create_time createTime,update_time updateTime from emp where<if test="name!=null">name like concat('%',#{name},'%')</if><if test="gender!=null">and gender=#{gender}</if><if test="begin!=null and end!=null">and entrydate between #{begin} and #{end}</if>

2.<where>

where元素只会在子元素有内容的情况下才插入where语句。而且会自动去除子句的开头的AND或OR

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--namespace为Mapper接口的全限定名-->
<mapper namespace="com.itheima.springbootmybatisquickstart.mapper.EmpMapper"><!--id为函数名,resultType为返回的对象的全限定名--><select id="IndistinctSelect" resultType="com.itheima.springbootmybatisquickstart.pojo.Emp"><!--执行的SQL语句-->select id, username, password, name, gender, image, job, entrydate, dept_id deptId, create_time createTime,update_time updateTime from emp<where><if test="name!=null">name like concat('%',#{name},'%')</if><if test="gender!=null">and gender=#{gender}</if><if test="begin!=null and end!=null">and entrydate between #{begin} and #{end}</if></where></select>
</mapper>

3.<set>

动态地在行首插入SET关键字,并会删除额外的逗号。(用在update语句中)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--namespace为Mapper接口的全限定名-->
<mapper namespace="com.itheima.springbootmybatisquickstart.mapper.EmpMapper"><update id="update">update emp<set><if test="username!=null">username=#{username},</if><if test="name!=null">name=#{name},</if><if test="gender!=null">gender=#{gender},</if><if test="image!=null">image=#{image},</if><if test="job!=null">job=#{job},</if><if test="entrydate!=null">entrydate=#{entrydate},</if><if test="deptId!=null">dept_id=#{deptId},</if><if test="updateTime!=null">update_time=#{updateTime}</if></set>where id = #{id}</update>
</mapper>

4.<foreach>

 

5.<sql>

定义可重复的SQL片段

 <sql id="commonSelect">select id, username, password, name, gender, image, job, entrydate, dept_id deptId, create_time createTime,update_time updateTime from emp</sql>

6.<include>

 通过属性refid,指定包含的sql片段

<include refid="commonSelect"/>

http://www.dtcms.com/wzjs/41627.html

相关文章:

  • 预约网免费建站流程seo技巧与技术
  • 网站开发与建设主要干什么网站友情链接怎么弄
  • 邢台网站开发培训学校代写文章兼职
  • 广州建筑公司招聘信息深圳优化网站
  • html5和ria网站设计谷歌浏览器官方app下载
  • 网站怎么做 吸引人百度最新秒收录方法2023
  • 文化传播做网站推广吗南昌seo代理商
  • 紫金网站建设公司百度推广代理
  • 网站建设策目标seo培训师
  • 如何做购物返佣金网站东莞网络推广招聘
  • 网站改版 降权企业如何进行搜索引擎优化
  • 个人站长做导航网站怎么给公司做网站推广
  • 做标书需要用到哪些网站查资料今日特大新闻新事
  • 煎蛋无聊图 wordpressseo还能赚钱吗
  • 济南网站开发设计网址搜索引擎
  • 学做网站在哪里快速排名提升
  • 无视隐私的十大软件seo收费标准多少
  • 专门做推荐的网站linux网站入口
  • 开发公司预算员工作内容及职责深圳百度快速排名优化
  • 网站建设总计seo建站公司
  • 网站建设就选国家高新技术企业
  • 网站建设公司找哪里优化大师哪个好
  • 兼职python做网站谷歌推广怎么开户
  • 怎么做国外的网站 卖东西网页设计软件
  • 网站里滚动的图片怎么做的站长工具服务器查询
  • 注册公司在哪个网站系统搜索引擎优化什么意思
  • 百度快照网站怎么做seo网站内容优化有哪些
  • 湘潭整站优化电子商务网站建设方案
  • 文学网站开发设计报告谷歌推广公司哪家好
  • 网站建设 中企动力 扬州百度平台订单查询