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

怎么设置网站默认首页什么是h5宣传

怎么设置网站默认首页,什么是h5宣传,西安市住宅和城乡建设局网站,世界十大搜索引擎及地址目录 if where set ctrl alt l格式化SQL语句 随着用户的输入或外部条件的变化而变化的SQL称为动态SQL if <if>用来判断条件是否成立&#xff0c;使用test属性进行条件判断&#xff0c;如果true&#xff0c;则拼接SQL where wehre元素只会在有条件成立的情况下才插入…

目录

if

where

set


ctrl + alt + l格式化SQL语句

 随着用户的输入或外部条件的变化而变化的SQL称为动态SQL

if

<if>用来判断条件是否成立,使用test属性进行条件判断,如果true,则拼接SQL 

where

wehre元素只会在有条件成立的情况下才插入where子句,而且会自动去除开头的AND或OR

如果存在只传递姓名的情况,之前的程序会无法成功查询,可以通过动态SQL解决上述问题 

EmpMapper.xml内容如下

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.EmpMapper"><!--resultType单条记录所封装的内容--><select id="list" resultType="com.itheima.pojo.Emp">select *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>order by update_time desc</select>
</mapper>

 SpringbootMybatisCrudApplicationTests.java内容如下

package com.itheima;import com.itheima.mapper.EmpMapper;
import com.itheima.pojo.Emp;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import java.util.List;@SpringBootTest
class SpringbootMybatisCrudApplicationTests {@Autowiredprivate EmpMapper empMapper;@Testpublic void testSelect(){List<Emp> list = empMapper.list(null,(short)1,null,null);System.out.println(list);}}

 运行结果如下 

set

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

将id为18的员工的username改为Tom111,name改为Tom111,gender改为2,其他不变

按照之前的方法进行更新会使其他值均变为null

可以通过动态SQL解决

EmpMapper.xml内容如下

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.EmpMapper"><!--resultType单条记录所封装的内容--><update id="update">update emp<set><if test="username != null">username=#{username},</if><if test="password != null">password=#{password},</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>

EmpMapper.java内容如下 

package com.itheima.mapper;import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;@Mapper
public interface EmpMapper {public void update(Emp emp);}

此次更新id为19的员工,SpringbootMybatisCrudApplicationTests.java内容如下

package com.itheima;import com.itheima.mapper.EmpMapper;
import com.itheima.pojo.Emp;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import java.time.LocalDateTime;@SpringBootTest
class SpringbootMybatisCrudApplicationTests {@Autowiredprivate EmpMapper empMapper;@Testpublic void testUpdate(){Emp emp = new Emp();emp.setId(19);emp.setUsername("Tom2222");emp.setName("Tom222");emp.setGender((short)1);emp.setUpdateTime(LocalDateTime.now());empMapper.update(emp);}}

 运行结果如下,发现只更新了四个字段,其余字段不变

http://www.yayakq.cn/news/306075/

相关文章:

  • 网站建设与管理 期末制作单页网站
  • 金融保险网站模板做品牌形象网站
  • 建网站的公司德阳建网站的公司wordpress仿微博主题
  • 网站开发文档网站网站地图格式
  • 做学校网站用什么模版外贸资讯平台
  • 做网站时怎样图片上传怎么才能让图片不变形_有什么插件吗server酱 wordpress
  • 给客户做网站0511城市建设网站棚户区改造
  • 太平洋网站开发营销型网站开发营销
  • mvc网站建设设计报告搭建公众号平台需要多少钱
  • 顺德网站建设公司杭州 网站开发
  • 商城类的网站怎么做学院网站建设需求分析目录
  • 网站开发需要会什么wordpress ueditor
  • 哪些网站是用h5做的网站建设模拟软件
  • 哪里有做网站排名优化装修公司前十强加盟
  • 网站开发合作运营平台合同网站搭建培训学校
  • 贵州省房屋和城市建设厅官方网站网站建设所需要的技术
  • 网站开发跟网页制作外包做网站要十几万
  • 网站的登录界面是怎么做的大连网站维护
  • 西安户县建设厅网站用帝国软件做网站的心得
  • 石城网站建设脚本外链生成工具
  • 怎么阻止网站博爱网站建设
  • 中卫网站推广制作百度对网站建设公司
  • 引流推广平台是什么意思北京网站制作网站优化
  • 怎么让自己的网站通过域名访问不了网站名称和备案的不一样
  • 宁波企业网站排名方法网站运营维护工作内容
  • 暖通设计网站推荐坪地网站建设效果
  • 网站建设无形资产的账务处理tp框架做商城网站怎么用缓存
  • 手机版网站系统wordpress出售功能插件
  • 网站建设用英文怎么说网站开发洲际
  • 专门做婚纱儿童摄影网站网络运营是做什么的