网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

有哪些遍历BOM表的SQL函数结构

本篇内容主要讲解“有哪些遍历BOM表的SQL函数结构”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“有哪些遍历BOM表的SQL函数结构”吧!

十载的丰林网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网整合营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整丰林建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联建站从事“丰林网站设计”,“丰林网站推广”以来,每个客户项目都认真落实执行。

表结构如下:

ptypesubptypeamount

aa.120

aa.215

aa.310

a.1a.1.120

a.1a.1.215

a.1a.1.330

a.2a.2.110

a.2a.2.220

a.1.1a.1.1.145

a.1.1a.1.1.215

a.2.1a.2.1.120

a.2.2a.2.2.113

createtablematgroup(parentgroupvarchar(50),childgroupvarchar(50),mountfloat)insertintomatgroupselect'a','a.1',20unionselect'a','a.2',15unionselect'a','a.3',10unionselect'a.1','a.1.1',20unionselect'a.1','a.1.2',15unionselect'a.1','a.1.3',30unionselect'a.2','a.2.1',10unionselect'a.2','a.2.2',20unionselect'a.1.1','a.1.1.1',45unionselect'a.1.1','a.1.1.2',15unionselect'a.2.1','a.2.1.1',20unionselect'a.2.2','a.2.2.1',13

遍历BOM表的SQL函数结构有哪些

函数如下:

createFUNCTIONfn_aaa(@matgroupvarchar(50),@mountint)RETURNS@retPLExpandTABLE(parentgroupvarchar(50),childgroupvarchar(50),mountfloat)ASBEGINDECLARE@RowsAddedintdeclare@PLExpandTable(parentgroupvarchar(50),childgroupvarchar(50),mountfloat,processedtinyintdefault(0))INSERT@PLExpandSELECTb.parentgroup,b.childgroup,@mount*b.mount,0FROMmatgroupbWHEREb.parentgroup=@matgroupSET@RowsAdded=@@rowcount--WhilenewemployeeswereaddedinthepreviousiterationWHILE@RowsAdded>0BEGIN/*Markallemployeerecordswhosedirectreportsaregoingtobefoundinthisiterationwithprocessed=1.*/UPDATE@PLExpandSETprocessed=1WHEREprocessed=0--Insertemployeeswhoreporttoemployeesmarked1.INSERT@PLExpandSELECTa.parentgroup,a.childgroup,a.mount*b.mount,0FROMmatgroupainnerjoin@PLExpandbona.parentgroup=b.childgroupwhereb.processed=1SET@RowsAdded=@@rowcount/*Markallemployeerecordswhosedirectreportshavebeenfoundinthisiteration.*/UPDATE@PLExpandSETprocessed=2WHEREprocessed=1END--copytotheresultofthefunctiontherequiredcolumnsINSERT@retPLExpandSELECTparentgroup,childgroup,mountFROM@PLExpandRETURNEND

调用方法如下:

select*fromfn_aaa('a.1')

意思是找出a.1下的所有儿子及孙子。

到此,相信大家对“有哪些遍历BOM表的SQL函数结构”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


标题名称:有哪些遍历BOM表的SQL函数结构
转载来源:http://bjjierui.cn/article/jioehi.html

其他资讯