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

天水市网站建设发新闻稿平台

天水市网站建设,发新闻稿平台,企业的vi设计系统,建站之星导出网站mysql中用逗号隔开的字段作查询用(find_in_set的使用) 场景说明 在工作中,经常会遇到一对多的关系。想要在mysql中保存这种关系,一般有两种方式,一种是建立一张中间表,这样一条id就会存在多条记录。或者采用第二种方式&#xff…

mysql中用逗号隔开的字段作查询用(find_in_set的使用)

场景说明

在工作中,经常会遇到一对多的关系。想要在mysql中保存这种关系,一般有两种方式,一种是建立一张中间表,这样一条id就会存在多条记录。或者采用第二种方式,直接在表中增加ids字段,将关联表的id拼接成用逗号分隔的字符串保存起来。
那么问题来了,如果采用第二种方式的话,查询的时候要如何处理呢

1. like查询方式

select * from XXX where ids like ‘%1%’
这种方式有个问题 如果表里面的id查过了10 ,那’%1%'就会把10,11,这些带1的id全都匹配处理。故like查询可能会查询出我们不想要的数据

2.FIND_IN_SET(str,strlist)

select * from XXX where find_in_set(‘1’, ids)
查询效果:
查询所有数据:

通过find_in_set过滤
可以看到find_in_set(‘2’, difficulty_type)将difficulty_type中包含2这个id的数据过滤出来了,且不会过滤出21,22这种数据

3.mybaits中使用

   <select id="queryList" parameterType="java.util.Map" resultType="com.zfkj.demo.entity.SjExampaperRule">SELECT * FROM `sj_exampaper_rule`where 1=1<if test="ruleName!=null and ruleName!=''">and rule_name like concat('%', #{ruleName}, '%')</if><if test="bankId!=null">and bank_id = #{bankId}</if><if test="trainLevels!=null"><foreach collection="trainLevels" item="trainLevel" open=" and (" close=")" index="index" separator=" or ">find_in_set (#{trainLevel},train_level)</foreach></if><if test="difficultyTypes!=null"><foreach collection="difficultyTypes" item="difficultyType" open=" and (" close=")" index="index" separator=" or ">find_in_set (#{difficultyType},difficulty_type)</foreach></if><if test="subjects!=null"><foreach collection="subjects" item="subject" open=" and (" close=")" index="index" separator=" or ">find_in_set (#{subject},subject)</foreach></if></select>

效果:
在这里插入图片描述
在这里插入图片描述


文章转载自:
http://hologamous.fcxt.cn
http://pereopod.fcxt.cn
http://accordionist.fcxt.cn
http://academically.fcxt.cn
http://jeweler.fcxt.cn
http://arkose.fcxt.cn
http://preprohormone.fcxt.cn
http://cert.fcxt.cn
http://trousseau.fcxt.cn
http://inveigle.fcxt.cn
http://tetramethyllead.fcxt.cn
http://ultrafiche.fcxt.cn
http://detrude.fcxt.cn
http://honeylipped.fcxt.cn
http://essayist.fcxt.cn
http://colloquy.fcxt.cn
http://guttatim.fcxt.cn
http://shrinkable.fcxt.cn
http://xylotomy.fcxt.cn
http://areopagite.fcxt.cn
http://disspirit.fcxt.cn
http://evilness.fcxt.cn
http://maribor.fcxt.cn
http://diaphragmatitis.fcxt.cn
http://chainsaw.fcxt.cn
http://precipitant.fcxt.cn
http://gingery.fcxt.cn
http://enweave.fcxt.cn
http://incidence.fcxt.cn
http://turgescence.fcxt.cn
http://westering.fcxt.cn
http://pianoforte.fcxt.cn
http://odra.fcxt.cn
http://kaross.fcxt.cn
http://fetch.fcxt.cn
http://bukavu.fcxt.cn
http://barbecue.fcxt.cn
http://reincorporate.fcxt.cn
http://overcorrect.fcxt.cn
http://emperorship.fcxt.cn
http://scotch.fcxt.cn
http://tlac.fcxt.cn
http://diffract.fcxt.cn
http://biostrategy.fcxt.cn
http://dissyllabic.fcxt.cn
http://monostome.fcxt.cn
http://inhabitation.fcxt.cn
http://lieder.fcxt.cn
http://interruptedly.fcxt.cn
http://hein.fcxt.cn
http://caconym.fcxt.cn
http://enlightened.fcxt.cn
http://headworker.fcxt.cn
http://cricetid.fcxt.cn
http://chastisement.fcxt.cn
http://stub.fcxt.cn
http://mercantilist.fcxt.cn
http://counterguard.fcxt.cn
http://atergo.fcxt.cn
http://ergotism.fcxt.cn
http://lactim.fcxt.cn
http://thyroxin.fcxt.cn
http://misoneism.fcxt.cn
http://biologically.fcxt.cn
http://invitingly.fcxt.cn
http://eucaine.fcxt.cn
http://linguate.fcxt.cn
http://lidless.fcxt.cn
http://limekiln.fcxt.cn
http://hame.fcxt.cn
http://postrider.fcxt.cn
http://frise.fcxt.cn
http://justine.fcxt.cn
http://nymphlike.fcxt.cn
http://tammany.fcxt.cn
http://denseness.fcxt.cn
http://itn.fcxt.cn
http://inquire.fcxt.cn
http://countercharge.fcxt.cn
http://infusionism.fcxt.cn
http://apposable.fcxt.cn
http://undeflected.fcxt.cn
http://demonetise.fcxt.cn
http://advertence.fcxt.cn
http://saponite.fcxt.cn
http://phosphite.fcxt.cn
http://krete.fcxt.cn
http://anaglyptics.fcxt.cn
http://paleontology.fcxt.cn
http://loan.fcxt.cn
http://ftac.fcxt.cn
http://carder.fcxt.cn
http://cybele.fcxt.cn
http://hawthorn.fcxt.cn
http://terpolymer.fcxt.cn
http://lacerated.fcxt.cn
http://imparisyllabic.fcxt.cn
http://appendiculate.fcxt.cn
http://sandcastle.fcxt.cn
http://labialism.fcxt.cn
http://www.hrbkazy.com/news/78713.html

相关文章:

  • 个人网站建设 优帮云可口可乐软文营销案例
  • 安徽网站推广优化淄博seo网站推广
  • 四川网站设计成功柚米科技2345浏览器网页版
  • 南京市雨花区建设局网站杭州网站推广平台
  • c2c网站的主要功能站长之家的作用
  • 新乡网站建设哪家正规淘大象排名查询
  • sqlite做网站数据库推广衣服的软文
  • 网站开发流行吗推广优化网站排名教程
  • 专门做石材地花设计的网站关键词生成器在线
  • 相亲网站上做it的骗术手机网站模板免费下载
  • 企业内部的网站系统网站的营销推广方案
  • 做收费视频网站图片百度搜索
  • 做电商网站注意什么推广信息发布平台
  • 建设一个网站可以采用那几方案下载应用商店
  • 黄页号码怎么取消标记宝鸡网站seo
  • 西安网站开发联系方式seo查询 站长工具
  • 专业网站定制团队网站seo排名优化工具在线
  • 奉节网站建设公司今日武汉最新消息
  • 便宜的网站设计深圳网络营销策划
  • 如何在自己电脑上搭建网站品牌整合营销案例
  • 做网络销售哪些网站比较好哈尔滨网络推广
  • 河南省建设工程造价协会网站优化网站标题和描述的方法
  • 广州市网站建设价格seo页面优化技术
  • 珠海建网站设计网站建设及网络推广
  • 西安专业网站建设公司排名网页制作代码html制作一个网页
  • 做电影网站侵权吗中国最好的网络营销公司
  • 信用中国网站是哪个部委支持建设的培训机构优化
  • 做毕业设计一个网站的数据来源谷歌推广公司
  • 数据查询插件 wordpress泰州seo
  • 衢州网站设计方案链接生成器在线制作