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

国家企业信息查询网站软件系统设计流程

国家企业信息查询网站,软件系统设计流程,怎样做一个购物型的网站,厦门的网站if标签与where标签 if标签 test如果为true就会拼接查询条件&#xff0c;否则不会 当没有使用Param&#xff0c;test出现arg0/param1当使用Param&#xff0c;test为Param指定的值当使用Pojo&#xff0c;test为对象的属性名 select * from car where <if test"name!n…

if标签与where标签

if标签

test如果为true就会拼接查询条件,否则不会

  • 当没有使用@Param,test出现arg0/param1
  • 当使用@Param,test为@Param指定的值
  • 当使用Pojo,test为对象的属性名
select * from car where
<if test="name!=null || name!='' ">name like concat('%',${name},'%')
</if>
<if test="price!=null || price!='' ">and price=#{price}
</if>
...

注意日期不能判断为空字符串

如何所有条件都不满足上述代码会报错

解决

如果用 where 1=1 后面判断必须加and

select * from car where 1=1
<if test="name!=null || name!='' ">and name like concat('%',${name},'%')
</if>
<if test="price!=null || price!='' ">and price=#{price}
</if>
...

where标签

  • 所有条件都为空时,where子句不会生成
  • 自动去掉前面多余的and,or
select * from car 
<where><if test="name!=null || name!='' ">name like concat('%',${name},'%')</if><if test="price!=null || price!='' ">and price=#{price}</if>
</where>
...

trim标签

  • prefix在标签前面动态的添加属性值
  • suffix在标签后面动态的添加属性值
  • suffixOverrides去除标签内容后面中指定的属性值
  • prefixOverrides去除标签内容前面中指定的属性值
select * from car 
<trim prefix="where" suffixOverrides="and | or" prefixOverrides="" suffix=""><if test="name!=null || name!='' ">name like concat('%',${name},'%')</if><if test="price!=null || price!='' ">and price=#{price}</if>
</trim>

set标签

  • 主要用在update标签中,只会提交不为空的条件
  • 可以动态去除语句中多余的,
update  car 
<set><if test="name!=null || name!='' ">name=#{name} , </if><if test="price!=null || price!='' ">price=#{price} ,</if>
</set>
where id=#{id}

choose when otherwise标签

一般在多条件中只执行某一个条件查询

用法类似与 if else if else

selecr * from car
<where><choose><when test="name!=null || name!='' ">name=#{name} </when><when test="price!=null || price!='' ">price=#{price} </when><otherwise>id=#{id} <otherwise></choose>
<where>

因为只会满足一种查询条件所有不需要加and


forEach标签

  • collection为循环列表
  • item为循环元素
  • separator为循环元素之间的分隔符
  • open为标签前面加属性值
  • close为标签后面加属性值

批量删除

delete  from car where  id in(<foreach collection="ids" item="item" separator=",">#{item}</foreach>
)delete  from car where  id in<foreach collection="ids" item="item" open="(" separator=","  close=")">#{item}</foreach>delete  from car where  <foreach collection="ids" item="item" separator="or"  >id=#{item}</foreach>

批量插入

insert into  car( name, price)
values<foreach collection="list" item="item" separator=",">(#{item.name},#{item.price})</foreach>

sql与include标签

主要用于字段的封装和复用

<sql id="CarSql">id,car_num as  carNum,brand,guide_price as guidePrice,produce_time as produceTime,car_type as carType
</sql><select id="selectAll" resultType="com.example.webapplication.pojo.Car">select<include refid="CarSql"></include>from car
</select>
http://www.yayakq.cn/news/484586/

相关文章:

  • 建材网站免费模板百度图片收录提交入口
  • 中山市路桥建设有限公司网站wordpress主页 摘要
  • 论坛网站的建立设计页面尺寸图
  • 国外有网站备案制度吗重庆网站整合营销
  • 软件开发应该学什么专业优化方案
  • 怎么看一个网站做外链网页前端开发技术
  • 电子商务网站建设相关职位金华市建设局婺城分局网站
  • 百度推广是否做网站花生壳做网站需要备案
  • 苏小小移动网站企业邮箱给我一个
  • 建站最少需要多少钱wordpress 添加icon
  • 素马网站建设服务收费标准自己做的网站打不开是什么原因
  • 前端招聘网站前端性能优化有哪些方法
  • 分公司一般做网站吗苏州推荐网络公司建网站
  • 哪个网站做图文素材多flask 简易网站开发
  • 建站网站教程视频教程在线图片制作生成
  • 快速网站收录安全联盟可信任网站认证 网站
  • 高端企业网站建设好的公司银川百度做网站多少钱
  • 万博法务网站建设项目济南建站
  • muse网站设计解决方案视频教程赣州市人才网招聘信息查询信息
  • 网站开发定价域名注册局联系方式
  • 衡器行业网站建设模板深圳商城网站建设公司
  • 找工作网站哪个比较好自建企业网站模板下载
  • 苏州市住房建设局网站太原做响应式网站
  • 东莞市营销网站建设x wordpress theme
  • 学网站建设要什么宜昌网站建设选择宜昌慧享互动
  • 网站建设 广西wordpress前端登录按钮
  • 宁波建网站一站式服务科技网站大全
  • 临沂专业网站建设公司电话html编辑器代码
  • 做网站没有数据库文明网站建设总结
  • 企业建设网站的帮助爱情树表白网页在线制作