pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

      <small id='4LCpx'></small><noframes id='4LCpx'>

      • <bdo id='4LCpx'></bdo><ul id='4LCpx'></ul>

    1. <tfoot id='4LCpx'></tfoot>

    2. <i id='4LCpx'><tr id='4LCpx'><dt id='4LCpx'><q id='4LCpx'><span id='4LCpx'><b id='4LCpx'><form id='4LCpx'><ins id='4LCpx'></ins><ul id='4LCpx'></ul><sub id='4LCpx'></sub></form><legend id='4LCpx'></legend><bdo id='4LCpx'><pre id='4LCpx'><center id='4LCpx'></center></pre></bdo></b><th id='4LCpx'></th></span></q></dt></tr></i><div class="drhdl77" id='4LCpx'><tfoot id='4LCpx'></tfoot><dl id='4LCpx'><fieldset id='4LCpx'></fieldset></dl></div>
    3. <legend id='4LCpx'><style id='4LCpx'><dir id='4LCpx'><q id='4LCpx'></q></dir></style></legend>
    4. 如何根據(jù)該 XML 中的值更新 SQL 中的 XML

      How to Update XML in SQL based on values in that XML(如何根據(jù)該 XML 中的值更新 SQL 中的 XML)
      <legend id='bokOp'><style id='bokOp'><dir id='bokOp'><q id='bokOp'></q></dir></style></legend>

    5. <i id='bokOp'><tr id='bokOp'><dt id='bokOp'><q id='bokOp'><span id='bokOp'><b id='bokOp'><form id='bokOp'><ins id='bokOp'></ins><ul id='bokOp'></ul><sub id='bokOp'></sub></form><legend id='bokOp'></legend><bdo id='bokOp'><pre id='bokOp'><center id='bokOp'></center></pre></bdo></b><th id='bokOp'></th></span></q></dt></tr></i><div class="5ndrt7d" id='bokOp'><tfoot id='bokOp'></tfoot><dl id='bokOp'><fieldset id='bokOp'></fieldset></dl></div>

          <tfoot id='bokOp'></tfoot>

          <small id='bokOp'></small><noframes id='bokOp'>

            <tbody id='bokOp'></tbody>
          • <bdo id='bokOp'></bdo><ul id='bokOp'></ul>
              1. 本文介紹了如何根據(jù)該 XML 中的值更新 SQL 中的 XML的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                限時(shí)送ChatGPT賬號(hào)..

                我必須根據(jù)該 XML 的某些條件更新表的 XML.示例 XML:

                I have to update XML of table based on some conditions of that XML. Sample XML:

                <CountryValues>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>2</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>3</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>4</Month>
                    <PlaceValue>10</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Australia</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Australia</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Australia</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>4</PlaceValue>        
                  </CountryRow>
                 </CountryValues>
                

                每個(gè)國(guó)家/地區(qū)可以有多個(gè)地方.我必須根據(jù) Country 和 Places 進(jìn)行分組,然后我必須將 PlaceValues 更新為 null for PlaceValue = 0 除了 0 緊接在 PlaceValue > 1 之前.此示例中的示例,對(duì)于 Country = Brazil 和 PlaceName = 1,PlaceValue forMonth1 到 Month2 將為 Null 但 Month3 將保持為 0 作為其前一個(gè) Month4 大于 0.

                Each Country can have multiple Places. I have to group on the basis of Country and Places, then I have to update PlaceValues to null for PlaceValue = 0 except 0 which is immediately preceding PlaceValue > 1. Example in this sample, for Country = Brazil and PlaceName = 1, PlaceValue for Month1 to Month2 will be Null but Month3 will remain 0 as its preceding Month4 which is greate than 0.

                推薦答案

                基本上,我看到了兩種處理方法.首先 - 將 xml 拆分為 sql 表/派生表,完成您的工作,然后再次組合成 xml.

                Basically, I see 2 ways of dealing with this. First - split xml to sql table/derived table, do your work and then combine into xml again.

                declare @data xml = 
                '<CountryValues>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>2</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>3</Month>
                    <PlaceValue>0</PlaceValue>        
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>4</Month>
                    <PlaceValue>10</PlaceValue>        
                  </CountryRow>
                 </CountryValues>'
                
                ;with cte as (
                    select
                        t.c.value('CountryName[1]', 'nvarchar(max)') as CountryName,
                        t.c.value('PlaceName[1]', 'nvarchar(max)') as PlaceName,
                        t.c.value('Month[1]', 'int') as [Month],
                        t.c.value('PlaceValue[1]', 'int') as PlaceValue
                    from @data.nodes('CountryValues/CountryRow') as t(c)
                )
                select
                    c1.CountryName,
                    c1.PlaceName,
                    c1.[Month],
                    case
                        when c1.PlaceValue = 0 and isnull(c2.PlaceValue, 0) <= 1 then null
                        else c1.PlaceValue
                    end as PlaceValue
                from cte as c1
                    left outer join cte as c2 on c2.CountryName = c1.CountryName and c2.PlaceName = c1.PlaceName and c2.[Month] = c1.[Month] + 1
                for xml path('CountryRow'), root('CountryValues')
                
                ----------------------------------
                <CountryValues>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>1</Month>
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>2</Month>
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>3</Month>
                    <PlaceValue>0</PlaceValue>
                  </CountryRow>
                  <CountryRow>
                    <CountryName>Brazil</CountryName>
                    <PlaceName>Place 1</PlaceName>
                    <Month>4</Month>
                    <PlaceValue>10</PlaceValue>
                  </CountryRow>
                </CountryValues>
                

                第二種方法是在 xml 本身中使用 xquery.

                Second way would be to use xquery inside the xml itself.

                答案實(shí)際上取決于您所說(shuō)的緊接在 PlaceValue > 1 之前"是什么意思.我在這里假設(shè)這意味著 - 值 > 1 的月份之前的月份.

                The answer is really depends on what do you mean by "immediately preceding PlaceValue > 1". I've assumed here that this means - month right before month with value > 1.

                這篇關(guān)于如何根據(jù)該 XML 中的值更新 SQL 中的 XML的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產(chǎn)品、類別和元數(shù)據(jù)的 SQL 查詢 woocommerce/wordpress)
                Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數(shù)據(jù)庫(kù)列表和 SQL Server 實(shí)例使用的空間嗎?) - IT屋-程序員軟件開發(fā)
                How to create a login to a SQL Server instance?(如何創(chuàng)建對(duì) SQL Server 實(shí)例的登錄?)
                How to know the version and edition of SQL Server through registry search(如何通過(guò)注冊(cè)表搜索知道SQL Server的版本和版本)
                Why do I get a quot;data type conversion errorquot; with ExecuteNonQuery()?(為什么會(huì)出現(xiàn)“數(shù)據(jù)類型轉(zhuǎn)換錯(cuò)誤?使用 ExecuteNonQuery()?)
                How to show an image from a DataGridView to a PictureBox?(如何將 DataGridView 中的圖像顯示到 PictureBox?)
                • <legend id='yVz9v'><style id='yVz9v'><dir id='yVz9v'><q id='yVz9v'></q></dir></style></legend>
                    <tbody id='yVz9v'></tbody>

                    <bdo id='yVz9v'></bdo><ul id='yVz9v'></ul>
                    <i id='yVz9v'><tr id='yVz9v'><dt id='yVz9v'><q id='yVz9v'><span id='yVz9v'><b id='yVz9v'><form id='yVz9v'><ins id='yVz9v'></ins><ul id='yVz9v'></ul><sub id='yVz9v'></sub></form><legend id='yVz9v'></legend><bdo id='yVz9v'><pre id='yVz9v'><center id='yVz9v'></center></pre></bdo></b><th id='yVz9v'></th></span></q></dt></tr></i><div class="zlrzzpd" id='yVz9v'><tfoot id='yVz9v'></tfoot><dl id='yVz9v'><fieldset id='yVz9v'></fieldset></dl></div>

                    <small id='yVz9v'></small><noframes id='yVz9v'>

                      • <tfoot id='yVz9v'></tfoot>
                          主站蜘蛛池模板: 压力控制器,差压控制器,温度控制器,防爆压力控制器,防爆温度控制器,防爆差压控制器-常州天利智能控制股份有限公司 | 乙炔气体报警装置|固定式氯化氢检测仪|河南驰诚电气百科 | 膏剂灌装旋盖机-眼药水灌装生产线-西林瓶粉剂分装机-南通博琅机械科技 | 企业VI设计_LOGO设计公司_品牌商标设计_【北京美研】 | 产业规划_产业园区规划-产业投资选址及规划招商托管一体化服务商-中机院产业园区规划网 | 黑田精工电磁阀-CAMMOZI气缸-ROSS电磁-上海茂硕机械设备有限公司 | 砍排机-锯骨机-冻肉切丁机-熟肉切片机-预制菜生产线一站式服务厂商 - 广州市祥九瑞盈机械设备有限公司 | 南京种植牙医院【官方挂号】_南京治疗种植牙医院那个好_南京看种植牙哪里好_南京茀莱堡口腔医院 尼龙PA610树脂,尼龙PA612树脂,尼龙PA1010树脂,透明尼龙-谷骐科技【官网】 | 济南拼接屏_山东液晶拼接屏_济南LED显示屏—维康国际官网 | 药品/药物稳定性试验考察箱-埃里森仪器设备(上海)有限公司 | 银川美容培训-美睫美甲培训-彩妆纹绣培训-新娘化妆-学化妆-宁夏倍莱妮职业技能培训学校有限公司 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 南京种植牙医院【官方挂号】_南京治疗种植牙医院那个好_南京看种植牙哪里好_南京茀莱堡口腔医院 尼龙PA610树脂,尼龙PA612树脂,尼龙PA1010树脂,透明尼龙-谷骐科技【官网】 | 电力测功机,电涡流测功机,磁粉制动器,南通远辰曳引机测试台 | 安驭邦官网-双向万能直角铣头,加工中心侧铣头,角度头[厂家直销] 闸阀_截止阀_止回阀「生产厂家」-上海卡比阀门有限公司 | cnc精密加工_数控机械加工_非标平键定制生产厂家_扬州沃佳机械有限公司 | 对辊式破碎机-对辊制砂机-双辊-双齿辊破碎机-巩义市裕顺机械制造有限公司 | 校园文化空间设计-数字化|中医文化空间设计-党建|法治廉政主题文化空间施工-山东锐尚文化传播公司 | 丽陂特官网_手机信号屏蔽器_Wifi信号干扰器厂家_学校考场工厂会议室屏蔽仪 | 北京公寓出租网-北京酒店式公寓出租平台 | 工控机-工业平板电脑-研华工控机-研越无风扇嵌入式box工控机 | 茶楼装修设计_茶馆室内设计效果图_云臻轩茶楼装饰公司 | 石家庄律师_石家庄刑事辩护律师_石家庄取保候审-河北万垚律师事务所 | 广东风淋室_广东风淋室厂家_广东风淋室价格_广州开源_传递窗_FFU-广州开源净化科技有限公司 | Type-c防水母座|贴片母座|耳机接口|Type-c插座-深圳市步步精科技有限公司 | 万家财经_财经新闻_在线财经资讯网 | 山东钢格板|栅格板生产厂家供应商-日照森亿钢格板有限公司 | 工业废水处理|污水处理厂|废水治理设备工程技术公司-苏州瑞美迪 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 哈尔滨发电机,黑龙江柴油发电机组-北方星光 | 风淋室生产厂家报价_传递窗|送风口|臭氧机|FFU-山东盛之源净化设备 | TPE_TPE热塑性弹性体_TPE原料价格_TPE材料厂家-惠州市中塑王塑胶制品公司- 中塑王塑胶制品有限公司 | 丝杆升降机-不锈钢丝杆升降机-非标定制丝杆升降机厂家-山东鑫光减速机有限公司 | 楼梯定制_楼梯设计施工厂家_楼梯扶手安装制作-北京凌步楼梯 | 广东机电安装工程_中央空调工程_东莞装饰装修-广东粤标建设有限公司 | 【铜排折弯机,钢丝折弯成型机,汽车发泡钢丝折弯机,线材折弯机厂家,线材成型机,铁线折弯机】贝朗折弯机厂家_东莞市贝朗自动化设备有限公司 | 车间除尘设备,VOCs废气处理,工业涂装流水线,伸缩式喷漆房,自动喷砂房,沸石转轮浓缩吸附,机器人喷粉线-山东创杰智慧 | 华溶溶出仪-Memmert稳定箱-上海协烁仪器科技有限公司 | 螺旋丝杆升降机-SWL蜗轮-滚珠丝杆升降机厂家-山东明泰传动机械有限公司 | 逗网红-抖音网红-快手网红-各大平台网红物品导航 | BOE画框屏-触摸一体机-触控查询一体机-触摸屏一体机价格-厂家直销-触发电子 | 镀锌角钢_槽钢_扁钢_圆钢_方矩管厂家_镀锌花纹板-海邦钢铁(天津)有限公司 | 宠物店加盟_宠物连锁店_开宠物店-【派多格宠物】 |