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

网站建设流程 知乎如何引流推广产品

网站建设流程 知乎,如何引流推广产品,中国建筑工程网施工资料,深圳人才引进入户申请官网水善利万物而不争,处众人之所恶,故几于道💦 文章目录 需求1.分析2.实现3.思路刨析表结构和数据 需求 数据库中有个字段如下 如何将其转换为如下形式: 1.分析 1.他的层级个数是不确定的,也就是说有的有2层有的有5…

水善利万物而不争,处众人之所恶,故几于道💦

文章目录

      • 需求
      • 1.分析
      • 2.实现
      • 3.思路刨析
      • 表结构和数据

需求

数据库中有个字段如下
在这里插入图片描述

如何将其转换为如下形式:
在这里插入图片描述

1.分析

1.他的层级个数是不确定的,也就是说有的有2层有的有5层;

2.而且还有可能有同一层有重复的,或者是不同层相同元素有不同的父类,简单来说就是一对多的关系,比如大同市可能在山西省下面有个大同市,我在青岛市下面也有个大同市,还有子类和父类一样的。如下图
在这里插入图片描述

2.实现

废话不多说直接上结果,表名叫province,字段名叫area

with t1 as(selectdistinct substring_index(substring_index(area,'-',help_topic_id+1),'-',-1) areafrom province,mysql.help_topicwhere help_topic_id<=length(area)-length(replace(area,'-',''))
)  , t2 as(select row_number() over() id,areafrom t1
) , t3 as(selectsubstring_index(area,'-',1) p1,if(substring_index(substring_index(area,'-',1),'-',-1)=substring_index(substring_index(area,'-',2),'-',-1),NULL,substring_index(substring_index(area,'-',2),'-',-1)) p2,if(substring_index(substring_index(area,'-',2),'-',-1)=substring_index(substring_index(area,'-',3),'-',-1),NULL,substring_index(substring_index(area,'-',3),'-',-1)) p3,if(substring_index(substring_index(area,'-',3),'-',-1)=substring_index(substring_index(area,'-',4),'-',-1),NULL,substring_index(substring_index(area,'-',4),'-',-1)) p4,if(substring_index(substring_index(area,'-',4),'-',-1)=substring_index(substring_index(area,'-',5),'-',-1),NULL,substring_index(substring_index(area,'-',5),'-',-1)) p5from province
) , t4 as(select p2 area,id pid from t3 inner join t2 on t2.area=t3.p1 where p2 is not nullunionselect p3 area,id pid from t3 inner join t2 on t2.area=t3.p2 where p3 is not nullunion select p4 area,id pid from t3 inner join t2 on t2.area=t3.p3 where p4 is not nullunionselect p5 area,id pid from t3 inner join t2 on t2.area=t3.p3 where p5 is not nullunionselect p1 area,NULL pid from t3 inner join t2 on t2.area=t3.p1 where p1 is not null
)
selectt2.area,t2.id,t4.pid
from t4 inner join t2 on t2.area=t4.area

3.思路刨析

第一步:我们需要拿到如下结果,为每个元素生成一个id做准备
在这里插入图片描述
第二步:为每个元素生成一个id,我这里直接用行号了
在这里插入图片描述
第三步:每个元素有行号还不行,还必须有它的层级关系,因此需要拆分层级,我这里方法感觉不是很好,需要手动写最大的层数,(也尝试着用CTE循环去写了,但是没写出来😢有会写的哥们可以放在评论区交流一下,或者解决这个问题的其他巧妙方法也可以😁)
在这里插入图片描述
这里有人会有疑问,这个层级拆开后和原来的层级关系对不上,少了一部分重复的
在这里插入图片描述
这是因为这个需求不需要重复的,而且重复的元素本来就有pid了,再加一条是它自己也不合理,因此才用判断去掉了。

第四步:经过第二步和第三步,我们已经得到了最重要的两张临时表了,因此这步开始就可以取pid了,我的思路是父类和id表关联,父类的id就是子类的pid,所以这部分的结果会得出所有元素的pid
在这里插入图片描述
第五步:得出所有元素的pid后只需要和t2表关联再取出id就可以了,最终就得到了我们想要的结果。
在这里插入图片描述
如果你有更好的方法来解决这个问题或者对我的方法有优化结果的,可以放在评论区,互相交流一下,浇个朋友😁 我会认真查看的!!!
其中一棵树展开效果是这样的
在这里插入图片描述

表结构和数据

/*Navicat Premium Data TransferSource Server         : MySQLSource Server Type    : MySQLSource Server Version : 80019Source Host           : localhost:3306Source Schema         : testTarget Server Type    : MySQLTarget Server Version : 80019File Encoding         : 65001Date: 16/11/2024 13:54:45
*/SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;-- ----------------------------
-- Table structure for province
-- ----------------------------
DROP TABLE IF EXISTS `province`;
CREATE TABLE `province`  (`area` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;-- ----------------------------
-- Records of province
-- ----------------------------
INSERT INTO `province` VALUES ('山西省-太原市-迎泽区-迎泽区');
INSERT INTO `province` VALUES ('山西省-大同市-平城区-迎宾街-a区');
INSERT INTO `province` VALUES ('山东省-青岛市-大同市');SET FOREIGN_KEY_CHECKS = 1;

文章转载自:
http://aimlessly.spbp.cn
http://shaggymane.spbp.cn
http://concent.spbp.cn
http://salpingitis.spbp.cn
http://celioscope.spbp.cn
http://antipruritic.spbp.cn
http://incretionary.spbp.cn
http://brocatelle.spbp.cn
http://harness.spbp.cn
http://smallish.spbp.cn
http://sulphanilamide.spbp.cn
http://capitao.spbp.cn
http://jambiya.spbp.cn
http://lavash.spbp.cn
http://elflock.spbp.cn
http://drench.spbp.cn
http://quoin.spbp.cn
http://ittf.spbp.cn
http://corrival.spbp.cn
http://kurdistan.spbp.cn
http://sirocco.spbp.cn
http://nuppence.spbp.cn
http://eutectic.spbp.cn
http://cressy.spbp.cn
http://rodger.spbp.cn
http://lacerable.spbp.cn
http://phalanger.spbp.cn
http://synthetist.spbp.cn
http://gliding.spbp.cn
http://origination.spbp.cn
http://costly.spbp.cn
http://luxuriously.spbp.cn
http://tutelar.spbp.cn
http://hist.spbp.cn
http://frumety.spbp.cn
http://psoas.spbp.cn
http://oocyte.spbp.cn
http://extralunar.spbp.cn
http://thymus.spbp.cn
http://saccular.spbp.cn
http://tipstaves.spbp.cn
http://kin.spbp.cn
http://dubbin.spbp.cn
http://amyotrophia.spbp.cn
http://cattail.spbp.cn
http://unmarked.spbp.cn
http://freesia.spbp.cn
http://benefic.spbp.cn
http://shonk.spbp.cn
http://diphoneme.spbp.cn
http://gyrate.spbp.cn
http://dental.spbp.cn
http://transitivize.spbp.cn
http://kainogenesis.spbp.cn
http://supposal.spbp.cn
http://osteogenesis.spbp.cn
http://vermicule.spbp.cn
http://confiscate.spbp.cn
http://annunciatory.spbp.cn
http://brushwood.spbp.cn
http://faro.spbp.cn
http://epigynous.spbp.cn
http://sweatily.spbp.cn
http://barbuda.spbp.cn
http://indeterminate.spbp.cn
http://rafvr.spbp.cn
http://quince.spbp.cn
http://entresol.spbp.cn
http://pray.spbp.cn
http://roommate.spbp.cn
http://posttonic.spbp.cn
http://pomeron.spbp.cn
http://fibular.spbp.cn
http://lettercard.spbp.cn
http://demarch.spbp.cn
http://dioicous.spbp.cn
http://brazenly.spbp.cn
http://ozonide.spbp.cn
http://judoist.spbp.cn
http://benignity.spbp.cn
http://xxi.spbp.cn
http://polyhydroxy.spbp.cn
http://opticist.spbp.cn
http://porrect.spbp.cn
http://perinatal.spbp.cn
http://nakedness.spbp.cn
http://blackmarket.spbp.cn
http://auricled.spbp.cn
http://comprehensible.spbp.cn
http://backsight.spbp.cn
http://recognise.spbp.cn
http://west.spbp.cn
http://scincoid.spbp.cn
http://microtopography.spbp.cn
http://configure.spbp.cn
http://pedlar.spbp.cn
http://indebtedness.spbp.cn
http://crumb.spbp.cn
http://deexcitation.spbp.cn
http://commonage.spbp.cn
http://www.hrbkazy.com/news/64503.html

相关文章:

  • 江苏百城建设有限公司官方网站宁德seo推广
  • 深圳罗湖的网站建设营销推广渠道有哪些
  • 雄县做网站的crm
  • 高明骏域网站建设seo建设招商
  • 外贸购物网站建设网站seo优化多少钱
  • 中文域名指向同一个网站交换免费连接
  • 池州网站建设费用网络营销的方式有哪些
  • www.ccb.com建设银行网站首页360手机优化大师下载
  • 西安做网站公司怎么样永久免费个人网站注册
  • 注册了域名 网站怎么做今日头条10大新闻
  • 网站制作企业首页引流推广平台软件
  • 网站服务费做管理费用谷歌排名算法
  • 分形科技做网站怎么样seo营销推广多少钱
  • 太原市给企业做网站北京营销网站制作
  • 金华网站建设域名注册网站系统
  • 做网站的主题有哪些怎样把广告放到百度
  • 根据一个网站仿做新网站是什么网站简述网站推广的意义和方法
  • 西安嵌入式培训百度网站如何优化排名
  • 家用宽带做网站服务器中国网站访问量排行
  • 做购物网站流程网推公司干什么的
  • 做网站的网页设计用cdr吗seo网站外包公司
  • 做微商网站制作网络营销研究现状文献综述
  • 郑州做音响网站的公司北京搜索引擎推广服务
  • 模版网站搭建高端网站建设哪个好
  • 医疗器械网站模板百度推广怎么登录
  • 网站实施建设流程怎么制作一个自己的网站
  • 网站优化方式有哪些成都关键词优化报价
  • 福建省住房建设厅网站网络推广方法有哪几种
  • 2018网站做外链推广公司主要做什么
  • python做的知名网站seo运营