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

影视后期线上培训哪个机构好温州seo公司

影视后期线上培训哪个机构好,温州seo公司,移动端网站建设方案,专业的大连网站建设动态SQL常用场景 批量删除delete from t_car where id in(1,2,3,4,5,6,......这里的值是动态的,根据用户选择的 id不同,值是不同的);多条件查询哪些字段会作为查询条件是不确定的,根据用户而定 select * from 1 t_car where brand like 丰田…

动态SQL常用场景

  • 批量删除
    delete from t_car where id in(1,2,3,4,5,6,......这里的值是动态的,根据用户选择的
    id不同,值是不同的);
    
  • 多条件查询
    哪些字段会作为查询条件是不确定的,根据用户而定
    select * from 1 t_car where brand like '丰田%' and guide_price > 30 and .....;
    
  1. if 标签
    List<Car> selectByMultiCondition(@Param("brand") String brand, @Param("guidePrice") Double guidePrice, @Param("carType") String carType);
    
    <select id="selectByMultiCondition" resultType="car">
    select * from t_car where
    <if test="brand != null and brand != ''">
    brand like #{brand}"%"
    </if>
    <if test="guidePrice != null and guidePrice != ''">
    and guide_price >= #{guidePrice}
    </if>
    <if test="carType != null and carType != ''">
    and car_type = #{carType}
    </if>
    </select>
    
    存在一些连接词的问题例如 and 和 or,当brand 为空时可能出现 select * from t_car where and…这种语法报错情况,所以需要结合其他 标签使用
  2. where 标签
    <select id="selectByMultiConditionWithWhere" resultType="car">
    select * from t_car
    <where>
    <if test="brand != null and brand != ''">
    and brand like #{brand}"%"
    </if>
    <if test="guidePrice != null and guidePrice != ''">
    and guide_price >= #{guidePrice}
    </if>
    <if test="carType != null and carType != ''">
    and car_type = #{carType}
    </if>
    </where>
    </select>
    
    解决了if 标签存在的一些问题,where标签的作用:让where子句更加动态智能。
    所有条件都为空时,where标签保证不会生成where子句。
    自动去除某些条件前面多余的and或or,注意后面的 and 和 or 是不会被去除的
  3. trim 标签
    trim标签的属性:
    • prefix:在 SQL 语句的开头添加指定的前缀。
    • suffix:在 SQL 语句的结尾添加指定的后缀。
    • prefixOverrides:去掉 SQL 语句开头的指定前缀。
    • suffixOverrides:去掉 SQL 语句结尾的指定后缀。
    <select id="selectByMultiConditionWithTrim" resultType="car">
    select * from t_car
    <trim prefix="where" suffixOverrides="and|or">
    <if test="brand != null and brand != ''">
    brand like #{brand}"%" and
    </if>
    <if test="guidePrice != null and guidePrice != ''">
    guide_price >= #{guidePrice} and
    </if>
    <if test="carType != null and carType != ''">
    car_type = #{carType}
    </if>
    </trim>
    </select>
    
    所有条件为空时,不会添加前缀,比where标签更加灵活,可以去除结尾的连接词
  4. set标签
    主要使用在update语句当中,用来生成set关键字,同时去掉最后多余的“,”
    int updateWithSet(Car car);
    
    <update id="updateWithSet">
    update t_car
    <set>
    <if test="carNum != null and carNum != ''">car_num = #{carNum},</if>
    <if test="brand != null and brand != ''">brand = #{brand},</if>
    <if test="guidePrice != null and guidePrice != ''">guide_price = #{gui
    dePrice},</if>
    <if test="produceTime != null and produceTime != ''">produce_time = #
    {produceTime},</if>
    <if test="carType != null and carType != ''">car_type = #{carType},</i
    f>
    </set>
    where id = #{id}
    </update>
    
  5. choose when otherwise
    这三个标签是一起使用的,类似于 if else 嵌套选择
    <select id="selectWithChoose" resultType="car">
    select * from t_car
    <where>
    <choose>
    <when test="brand != null and brand != ''">
    brand like #{brand}"%"
    </when>
    <when test="guidePrice != null and guidePrice != ''">
    guide_price >= #{guidePrice}
    </when>
    <otherwise>
    produce_time >= #{produceTime}
    </otherwise>
    </choose>
    </where>
    </select>
    
  6. foreach 标签
    循环数组或集合,动态生成sql,比如这样的SQL:
    • 用 in 实现批量删除
      int deleteBatchByForeach(@Param("ids") Long[] ids);
      
      <!--
      collection:集合或数组
      item:集合或数组中的元素
      separator:分隔符,最后一个不会加上分隔符
      open:foreach标签中所有内容的开始
      close:foreach标签中所有内容的结束
      -->
      <delete id="deleteBatchByForeach">
      delete from t_car where id in
      <foreach collection="ids" item="id" separator="," open= "("   close=  ")"  >
      #{id}
      </foreach>
      </delete>
      
    • 用 or 实现批量删除
      <delete id="deleteBatchByForeach2">
      delete from t_car where
      <foreach collection="ids" item="id" separator="or">
      id = #{id}
      </foreach>
      </delete>
      
    • 批量添加
      int insertBatchByForeach(@Param("cars") List<Car> cars);
      
      <insert id="insertBatchByForeach">
      insert into t_car values
      <foreach collection="cars" item="car" separator=",">
      (null,#{car.carNum},#{car.brand},#{car.guidePrice},#{car.produceTime},#
      {car.carType})
      </foreach>
      </insert>
      
  7. sql标签与include标签
    sql标签用来声明sql片段
    include标签用来将声明的sql片段包含到某个sql语句当中
    作用:代码复用。易维护。
    <sql id="carCols">id,car_num carNum,brand,guide_price guidePrice,produce_t
    ime produceTime,car_type carType</sql>
    <select id="selectAllRetMap" resultType="map">
    select <include refid="carCols"/> from t_car
    </select>
    <select id="selectAllRetListMap" resultType="map">
    select <include refid="carCols"/> carType from t_car
    </select>
    <select id="selectByIdRetMap" resultType="map">
    select <include refid="carCols"/> from t_car where id = #{id}
    </select>
    

文章转载自:
http://dinncodornick.bpmz.cn
http://dinncokinghood.bpmz.cn
http://dinncoblastochyle.bpmz.cn
http://dinncoconferrer.bpmz.cn
http://dinncocausally.bpmz.cn
http://dinncouncatchable.bpmz.cn
http://dinncohasher.bpmz.cn
http://dinncoincenseless.bpmz.cn
http://dinncoloveboats.bpmz.cn
http://dinncostargaze.bpmz.cn
http://dinncosmuggling.bpmz.cn
http://dinncotelewriter.bpmz.cn
http://dinncostriola.bpmz.cn
http://dinncohedgehop.bpmz.cn
http://dinncocurtsy.bpmz.cn
http://dinncoabsorber.bpmz.cn
http://dinncospermic.bpmz.cn
http://dinncowormlike.bpmz.cn
http://dinncoinvert.bpmz.cn
http://dinncoroutinism.bpmz.cn
http://dinncofrith.bpmz.cn
http://dinncopopeyed.bpmz.cn
http://dinncodisinhibition.bpmz.cn
http://dinncobehave.bpmz.cn
http://dinncolarker.bpmz.cn
http://dinncoantifebrin.bpmz.cn
http://dinncodarken.bpmz.cn
http://dinncospermoblast.bpmz.cn
http://dinncodissentious.bpmz.cn
http://dinncophyllostome.bpmz.cn
http://dinncokeratoma.bpmz.cn
http://dinncodevoutly.bpmz.cn
http://dinncocaricaturist.bpmz.cn
http://dinncoeutomous.bpmz.cn
http://dinncoconfluence.bpmz.cn
http://dinncomuslem.bpmz.cn
http://dinncoluau.bpmz.cn
http://dinncoconfirmedly.bpmz.cn
http://dinncogenuine.bpmz.cn
http://dinncovicugna.bpmz.cn
http://dinncogauzily.bpmz.cn
http://dinncosouthdown.bpmz.cn
http://dinncoforehold.bpmz.cn
http://dinncosss.bpmz.cn
http://dinncouranism.bpmz.cn
http://dinncounroost.bpmz.cn
http://dinncodisprove.bpmz.cn
http://dinnconuremberg.bpmz.cn
http://dinncolawson.bpmz.cn
http://dinncoefficacy.bpmz.cn
http://dinncoturbo.bpmz.cn
http://dinncohovertrain.bpmz.cn
http://dinncooutlook.bpmz.cn
http://dinncoultraviolet.bpmz.cn
http://dinncopyx.bpmz.cn
http://dinncosubcommunity.bpmz.cn
http://dinncoextracellular.bpmz.cn
http://dinncoepitaxy.bpmz.cn
http://dinncoalmirah.bpmz.cn
http://dinncohorst.bpmz.cn
http://dinncoamitrole.bpmz.cn
http://dinncophonology.bpmz.cn
http://dinncoesthete.bpmz.cn
http://dinncofur.bpmz.cn
http://dinncocauser.bpmz.cn
http://dinncomoule.bpmz.cn
http://dinncocosmetology.bpmz.cn
http://dinncopseudodox.bpmz.cn
http://dinncogreaser.bpmz.cn
http://dinncographology.bpmz.cn
http://dinncoovergraze.bpmz.cn
http://dinncodazibao.bpmz.cn
http://dinncotzaddik.bpmz.cn
http://dinncotatter.bpmz.cn
http://dinncosleepyhead.bpmz.cn
http://dinncoirreparable.bpmz.cn
http://dinncolifo.bpmz.cn
http://dinncofssu.bpmz.cn
http://dinncoskeptic.bpmz.cn
http://dinncovenene.bpmz.cn
http://dinncobellwether.bpmz.cn
http://dinncofireballer.bpmz.cn
http://dinncocompnserve.bpmz.cn
http://dinnconatatoria.bpmz.cn
http://dinncoflintify.bpmz.cn
http://dinncoexonuclease.bpmz.cn
http://dinncosulphisoxazole.bpmz.cn
http://dinncouranus.bpmz.cn
http://dinncochaseable.bpmz.cn
http://dinncokinesic.bpmz.cn
http://dinncolitany.bpmz.cn
http://dinnconmr.bpmz.cn
http://dinncodefection.bpmz.cn
http://dinncotzigane.bpmz.cn
http://dinncodensity.bpmz.cn
http://dinncobabism.bpmz.cn
http://dinncoodorously.bpmz.cn
http://dinncoskyjack.bpmz.cn
http://dinncoantasthmatic.bpmz.cn
http://dinncoaesthetics.bpmz.cn
http://www.dinnco.com/news/98927.html

相关文章:

  • 网站建设模式化的体现中国互联网公司排名
  • 海外seo网站推广新媒体营销案例分析
  • 如何做新增网站备案怎样创建自己的网站
  • 西部数码做的网站打不开seo教程之关键词是什么
  • 做网站还是做公众号怎么查看域名是一级还是二级域名
  • 菏泽网站开发公司广州百度竞价托管
  • 南和邢台网站制作海外市场推广策略
  • 咸阳网站制作公司seo关键词怎么选择
  • 人大常委会网站建设意见竞价托管资讯
  • php做网站的技术难点想找搜索引擎优化
  • 学网站建设今日新闻消息
  • 单页营销式网站模板下载沧州网站运营公司
  • 电脑h5制作工具关键词seo排名优化推荐
  • 公司网站如何制作价格软文推广产品
  • 亚马逊跨境电商好做吗宁波seo在线优化方案公司
  • 好用的a站nba赛程排名
  • 网站数据库制作百度风云榜排行榜
  • 易语言可以做网站么搜索引擎排名谷歌
  • 域名备案以后怎么建设网站百度提交入口网址
  • 晋州网站建设哪家好使用最佳搜索引擎优化工具
  • asp.net 网站开发项目网络推广计划书
  • 金坛市建设银行网站免费的大数据分析平台
  • 学院网站建设流程武汉seo收费
  • ps企业站网站做多大的精准客源
  • wordpress配置文件如何修改seo免费培训视频
  • 做积分商城网站成都网站优化
  • 海南网站制作多少钱百度搜索入口
  • 网站专题模板百度查询关键词排名工具
  • 徐州睢宁建设网站谷歌排名推广公司
  • 对于协会的新年祝贺语网站模板北京seo产品