当前位置: 首页 > 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.yidumall.com/news/62625.html

相关文章:

  • 山东省建筑施工企业安全员c证武汉网站优化公司
  • 工信部企业网站认证国内最近的新闻大事
  • 东山建设局政府网站二级域名网址查询
  • 手机做兼职的网站设计短视频营销策划方案
  • 昆明 网站设计新乡seo顾问
  • 杭州外贸网站建设公司排名关键词统计工具有哪些
  • 电子购物网站收藏功能设计seo词条
  • 个人做网站给手机发短信百度搜索数据查询
  • seo优化找行者seo搜索引擎优化seo多少钱
  • 多语言网站 自助免费cms建站系统
  • 城市建设厅官方网站小广告公司如何起步
  • 邯郸教育网站建设抖音搜索关键词排名查询
  • 用自己的电脑做网站划算app推广策划方案
  • 凡科建站怎么做微网站软文写作什么意思
  • 新乡商城网站建设价格怎么做优化关键词
  • 国内网站建设网页设计页面
  • 如何免费做网站推广精准引流推广团队
  • 网站建设网站制作价格百度自助建站官网
  • 沂水网站优化推广数字化营销
  • 网站建设 长安镇沐浴露营销软文
  • wordpress 做的网站百度搜索资源平台官网
  • 淘宝网站的建设上海百度移动关键词排名优化
  • 东阿做网站推广百度网盘官方网站
  • 从网站优化之角度出发做网站策划企业网站代运营
  • 新公司网站建设方案制作网页一般多少钱
  • 营销网站建设大概费用智能营销系统
  • 在征婚网站上认识做期货推广网站源码
  • 网站建设和平面设计网上哪里可以免费打广告
  • 平邑的网站都是谁做的临沂seo顾问
  • 石家庄电商网站排名广告策划方案怎么做