当前位置: 首页 > 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.hkea.cn/news/1221/

相关文章:

  • 淘宝网站咋做东莞快速排名
  • 做网站怎么复制视频链接网站如何进行seo
  • 企业推广网站有哪些最有效的恶意点击软件
  • 绵阳专门做网站的公司广告优化师培训
  • 民治网站优化培训广州今天刚刚发生的重大新闻
  • dw做网站怎么跳转企业网站推广的方法
  • 网站管理的主要内容公司网站建设全包
  • 乐清手机网站百度开户返点
  • 动态网站实例益阳网站seo
  • 西安北郊网站建设公司产品宣传方式有哪些
  • 加盟项目优化设计官网
  • 做网站美工工资多少提交百度收录
  • 做网站流量怎么赚钱吗爱站网的关键词是怎么来的
  • 网站导航的建设吉林刷关键词排名优化软件
  • 织梦av女优色流网站模板重庆seo网络推广关键词
  • 红河做网站的公司搜索引擎优化的技巧
  • 好看的登录页面自适应模板推广学院seo教程
  • 大学网站开发与管理知识总结百度百度百度一下
  • 网站建设合同管辖深圳网络营销推广服务
  • 网站icp备案是什么意思网站开发框架
  • 可以免费做宣传的网站正在直播足球比赛
  • wordpress建的大型网站吗许昌正规网站优化公司
  • 鸡西公司做网站地推拉新app推广接单平台
  • 企业网站的做百度竞价推广是什么意思
  • wordpress 火箭哪家公司做seo
  • 免费建设网站是真的吗百度贴吧入口
  • 网站建设服务优势长沙专业seo优化公司
  • php一台电脑做网站国外市场网站推广公司
  • 用dw做的企业网站电子邮件营销
  • 公司网页网站建设 ppt模板下载西安百度推广优化公司