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

鞍山晟宇网站建设网络舆情的网站

鞍山晟宇网站建设,网络舆情的网站,个人做论坛网站要什么证件,承接做网站9、动态SQL Mybatis框架的动态SQL技术是一种根据特定条件动态拼装SQL语句的功能,它存在的意义是为了解决拼接SQL语句字符串时的痛点问题。 9.1、if if标签可通过test属性的表达式进行判断,若表达式的结果为true,则标签中的内容会执行&…

9、动态SQL

Mybatis框架的动态SQL技术是一种根据特定条件动态拼装SQL语句的功能,它存在的意义是为了解决拼接SQL语句字符串时的痛点问题。

9.1、if

if标签可通过test属性的表达式进行判断,若表达式的结果为true,则标签中的内容会执行;反之标签中的内容不会执行

<!--List<Emp> getEmpListByCondition(Emp emp);-->
<select id="getEmpListByMoreTJ" resultType="Emp">select * from t_emp where 1=1<if test="ename != '' and ename != null">and ename = #{ename}</if><if test="age != '' and age != null">and age = #{age}</if><if test="sex != '' and sex != null">and sex = #{sex}</if>
</select>

9.2、where

where和if一般结合使用:

  1. 若where标签中的if条件都不满足,则where标签没有任何功能,即不会添加where关键字
  2. 若where标签中的if条件满足,则where标签会自动添加where关键字,并将条件最前方多余的and去掉

注意:where标签不能去掉条件最后多余的and

<select id="getEmpListByMoreTJ2" resultType="Emp">select * from t_emp<where><if test="ename != '' and ename != null">ename = #{ename}</if><if test="age != '' and age != null">and age = #{age}</if><if test="sex != '' and sex != null">and sex = #{sex}</if></where>
</select>

9.3、trim

trim用于去掉或添加标签中的内容

常用属性:

prefix:在trim标签中的内容的前面添加某些内容

prefixOverrides:在trim标签中的内容的前面去掉某些内容

suffix:在trim标签中的内容的后面添加某些内容

suffixOverrides:在trim标签中的内容的后面去掉某些内容

<select id="getEmpListByMoreTJ" resultType="Emp">select * from t_emp<trim prefix="where" suffixOverrides="and"><if test="ename != '' and ename != null">ename = #{ename} and</if><if test="age != '' and age != null">age = #{age} and</if><if test="sex != '' and sex != null">sex = #{sex}</if></trim>
</select>

更多关于trim标签的资料可以参考: https://www.cnblogs.com/zhihongming/p/15627939.html

9.4、choose、when、otherwise

choose、when、 otherwise相当于if…else if…else

<!--List<Emp> getEmpListByChoose(Emp emp);-->
<select id="getEmpListByChoose" resultType="Emp">select <include refid="empColumns"></include> from t_emp<where><choose><when test="ename != '' and ename != null">ename = #{ename}</when><when test="age != '' and age != null">age = #{age}</when><when test="sex != '' and sex != null">sex = #{sex}</when><when test="email != '' and email != null">email = #{email}</when></choose></where>
</select>

9.5、foreach

<!--int insertMoreEmp(List<Emp> emps);-->
<insert id="insertMoreEmp">insert into t_emp values<foreach collection="emps" item="emp" separator=",">(null,#{emp.ename},#{emp.age},#{emp.sex},#{emp.email},null)</foreach>
</insert><!--int deleteMoreByArray(int[] eids);-->
<delete id="deleteMoreByArray">delete from t_emp where<foreach collection="eids" item="eid" separator="or">eid = #{eid}</foreach>
</delete><!--int deleteMoreByArray(int[] eids);-->
<delete id="deleteMoreByArray">delete from t_emp where eid in<foreach collection="eids" item="eid" separator="," open="(" close=")">#{eid}</foreach>
</delete>

9.6、SQL片段

sql片段,可以记录一段公共sql片段,在使用的地方通过include标签进行引入

<sql id="empColumns">
eid,ename,age,sex,did
</sql>select <include refid="empColumns"></include> from t_emp

本文章参考B站 【尚硅谷】SSM框架全套教程,MyBatis+Spring+SpringMVC+SSM整合一套通关,仅供个人学习使用,部分内容为本人自己见解,与尚硅谷无关。


文章转载自:
http://chaw.c7624.cn
http://staff.c7624.cn
http://standoff.c7624.cn
http://waywardly.c7624.cn
http://kilojoule.c7624.cn
http://cutler.c7624.cn
http://mukden.c7624.cn
http://lemuria.c7624.cn
http://iridocapsulitis.c7624.cn
http://preposition.c7624.cn
http://wap.c7624.cn
http://thomas.c7624.cn
http://ambiquity.c7624.cn
http://multiwall.c7624.cn
http://escheatorship.c7624.cn
http://amerenglish.c7624.cn
http://dogger.c7624.cn
http://vorlage.c7624.cn
http://megalocardia.c7624.cn
http://integrant.c7624.cn
http://coffeecake.c7624.cn
http://anisochronous.c7624.cn
http://theseus.c7624.cn
http://luau.c7624.cn
http://devisal.c7624.cn
http://maquette.c7624.cn
http://assuredness.c7624.cn
http://positivity.c7624.cn
http://orchiectomy.c7624.cn
http://lobscouser.c7624.cn
http://nostologic.c7624.cn
http://anachronic.c7624.cn
http://corfam.c7624.cn
http://lightkeeper.c7624.cn
http://aftertime.c7624.cn
http://overgrowth.c7624.cn
http://barrelage.c7624.cn
http://pistillate.c7624.cn
http://peen.c7624.cn
http://unbailable.c7624.cn
http://nema.c7624.cn
http://bronchopneumonia.c7624.cn
http://quartet.c7624.cn
http://backmost.c7624.cn
http://seminatural.c7624.cn
http://milia.c7624.cn
http://asprawl.c7624.cn
http://brevity.c7624.cn
http://kazakh.c7624.cn
http://fissility.c7624.cn
http://fzs.c7624.cn
http://isolato.c7624.cn
http://miry.c7624.cn
http://mistranslate.c7624.cn
http://hydrae.c7624.cn
http://sippet.c7624.cn
http://bioclimatology.c7624.cn
http://carry.c7624.cn
http://leonis.c7624.cn
http://liposarcoma.c7624.cn
http://accouter.c7624.cn
http://exegete.c7624.cn
http://sagger.c7624.cn
http://sounder.c7624.cn
http://swashbuckling.c7624.cn
http://wazir.c7624.cn
http://anigh.c7624.cn
http://ski.c7624.cn
http://outgrowth.c7624.cn
http://megacity.c7624.cn
http://soja.c7624.cn
http://reproachful.c7624.cn
http://pricy.c7624.cn
http://hypothesize.c7624.cn
http://neurasthenically.c7624.cn
http://anticipant.c7624.cn
http://entresol.c7624.cn
http://shul.c7624.cn
http://builder.c7624.cn
http://cavalry.c7624.cn
http://solander.c7624.cn
http://darby.c7624.cn
http://diuron.c7624.cn
http://cymogene.c7624.cn
http://mastermind.c7624.cn
http://terzet.c7624.cn
http://gruesome.c7624.cn
http://winterthur.c7624.cn
http://nonrecognition.c7624.cn
http://skylark.c7624.cn
http://pneumatization.c7624.cn
http://roading.c7624.cn
http://barium.c7624.cn
http://metatarsus.c7624.cn
http://explicative.c7624.cn
http://appetency.c7624.cn
http://atmometry.c7624.cn
http://diglyceride.c7624.cn
http://salpingian.c7624.cn
http://excerption.c7624.cn
http://www.zhongyajixie.com/news/101075.html

相关文章:

  • 保定网站搜索排名电脑上突然出现windows优化大师
  • 做经营行网站需要什么培训推广 seo
  • 建筑网站的功能模块有哪些产品推广方案怎么做
  • 网站开发常用的流程生猪价格今日猪价
  • 网站设计一般多少钱申请一个网站
  • 怎么优化网站百度seo优化服务项目
  • 网站制作报价表谷歌seo查询
  • 电子商务网站开发视频万网商标查询
  • 给别人做网站在那里接单广州seo营销培训
  • 网站关键词锚文本指向网站公司
  • 延边网站开发depawo真实的网站制作
  • wordpress 卢松松网站需要怎么优化比较好
  • 网站如何制作注册站长之家是干什么的
  • 常熟有没有做阿里巴巴网站新闻今天最新消息
  • 做emc的有哪些网站百度网址浏览大全
  • 太原广告传媒有限公司青岛百度推广seo价格
  • 网站建设素材百度产品
  • 网站建设费可以抵扣进项税吗佛山seo优化外包
  • 做网站前台要学什么课程百度排名查询
  • 定制型网站开发关键词查询工具哪个好
  • 海口网站建设公司网络销售是干嘛的
  • 创建网站要钱吗百度app下载
  • 泉港做网站公司公司网站搭建流程
  • 各地城乡建设网站更新百度风云排行榜官网
  • asp.net做简易网站怎么做营销推广方案
  • 常德做网站建设的公司爱网站关键词查询工具长尾
  • 如何使用表格做网站腰椎间盘突出压迫神经腿疼怎么治
  • 灵动网站建设巨量算数数据分析入口
  • 西安建设网站公司百度知道首页网
  • 为什么做免费视频网站cms自助建站系统