久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<legend id='s2q6v'><style id='s2q6v'><dir id='s2q6v'><q id='s2q6v'></q></dir></style></legend>

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

      <tfoot id='s2q6v'></tfoot>
        • <bdo id='s2q6v'></bdo><ul id='s2q6v'></ul>
      1. <small id='s2q6v'></small><noframes id='s2q6v'>

      2. 如何從 SQL Server 2008 返回 XML,該 XML 結(jié)構(gòu)為多個(gè)選

        How to return XML from SQL Server 2008 that is structured with multiple selections sharing a common parent(如何從 SQL Server 2008 返回 XML,該 XML 結(jié)構(gòu)為多個(gè)選擇共享一個(gè)公共父級) - IT屋-程序員軟件開發(fā)技術(shù)分享社

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

            • <bdo id='UCJrS'></bdo><ul id='UCJrS'></ul>

                1. <small id='UCJrS'></small><noframes id='UCJrS'>

                2. <legend id='UCJrS'><style id='UCJrS'><dir id='UCJrS'><q id='UCJrS'></q></dir></style></legend>
                  本文介紹了如何從 SQL Server 2008 返回 XML,該 XML 結(jié)構(gòu)為多個(gè)選擇共享一個(gè)公共父級的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  限時(shí)送ChatGPT賬號..

                  我嘗試過使用FOR XML PATH"、FOR XML EXPLICIT"和FOR XML AUTO",但數(shù)據(jù)的結(jié)構(gòu)從來沒有使用正確的層次結(jié)構(gòu).

                  I've tried using "FOR XML PATH", "FOR XML EXPLICIT" and "FOR XML AUTO" but the data is never structured with the correct heirarchy.

                  基本上,我有一個(gè)父表(客戶)和 3 個(gè)子表.每個(gè)表都有一個(gè) customerid 列.從客戶表到 3 個(gè)子表中的每一個(gè)都存在一對多關(guān)系.

                  Basically, I have one parent table (Customers) and 3 child tables. Each table has a customerid column. There is a one-to-many relationship from the Customers table to each of the 3 child tables.

                  作為一個(gè)模擬示例,我有一個(gè)父Customers"表,還有另外 3 個(gè)表 - Products、Hobbies 和 Vehicles - 所有表都通過 customerid 與 Customers 表相關(guān).

                  As a mock example, I have a parent "Customers" table, and I have 3 other tables - Products, Hobbies and Vehicles - all related to the Customers table by a customerid.

                  實(shí)現(xiàn)以下結(jié)構(gòu)的SQL代碼是什么-

                  What is the SQL code to achieve the following kind of structure -

                  <Customers>
                      <Customer customerid="1" name="Fred">
                         <Products>
                             <Product productname="table" />
                             <Product productname="chair" />
                             <Product productname="wardrobe" />
                         </Products>
                         <Hobbies>
                             <Hobby hobbyname="Golf" />
                             <Hobby hobbyname="Swimming" />
                         </Hobbies>
                         <Vehicles>
                             <Vehicle name="Car" color="Red" />
                             <Vehicle name="Bicycle" color="Blue" />
                         </Vehicles>
                      </Customer>
                      <Customer customerid="2" name="Sue">
                         <Products>
                             <Product productname="CD player" />
                             <Product productname="Picture frame" />
                         </Products>
                         <Hobbies>
                             <Hobby hobbyname="Dancing" />
                             <Hobby hobbyname="Reading" />
                         </Hobbies>
                         <Vehicles>
                             <Vehicle name="Car" color="Yellow" />
                         </Vehicles>
                      </Customer>
                  </Customers>
                  

                  推薦答案

                  嘗試類似的方法 - 它使用 FOR XML PATH 和 subselects 為給定客戶創(chuàng)建鏈接"子節(jié)點(diǎn)(我將其限制為兩個(gè)子表 - 但您應(yīng)該了解它的要點(diǎn)"并能夠?qū)⑵鋽U(kuò)展到任意數(shù)量的鏈接子表):

                  Try something like this - it uses FOR XML PATH and subselects to create the "linked" sub-nodes for a given customer (I limited this to two sub tables - but you should get the "gist" of it and be able to extend it to any number of linked subtables):

                  SELECT
                      CustomerID AS '@CustomerID',
                      CustName AS '@Name',
                  
                      (SELECT ProductName AS '@productname'
                       FROM dbo.Products p
                       WHERE p.CustomerID = c.CustomerID  
                       FOR XML PATH('Product'), TYPE) AS 'Products',
                  
                      (SELECT HobbyName AS '@hobbyname'
                       FROM dbo.Hobbies h 
                       WHERE h.CUstomerID = c.CustomerID
                       FOR XML PATH('Hobby'), TYPE) AS 'Hobbies'
                  FROM
                      dbo.Customers c
                  FOR XML PATH('Customer'), ROOT('Customers')
                  

                  給我一??個(gè)類似的輸出:

                  Gives me an output something like:

                  <Customers>
                    <Customer CustomerID="1" Name="Fred">
                      <Products>
                        <Product productname="Table" />
                        <Product productname="Wardrobe" />
                        <Product productname="Chair" />
                      </Products>
                      <Hobbies>
                        <Hobby hobbyname="Golf" />
                        <Hobby hobbyname="Swimming" />
                      </Hobbies>
                    </Customer>
                    <Customer CustomerID="2" Name="Sue">
                      <Products>
                        <Product productname="CD Player" />
                        <Product productname="Picture frame" />
                      </Products>
                      <Hobbies>
                        <Hobby hobbyname="Dancing" />
                        <Hobby hobbyname="Gardening" />
                        <Hobby hobbyname="Reading" />
                      </Hobbies>
                    </Customer>
                  </Customers>
                  

                  這篇關(guān)于如何從 SQL Server 2008 返回 XML,該 XML 結(jié)構(gòu)為多個(gè)選擇共享一個(gè)公共父級的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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ù)庫列表和 SQL Server 實(shí)例使用的空間嗎?) - IT屋-程序員軟件開發(fā)
                  How to create a login to a SQL Server instance?(如何創(chuàng)建對 SQL Server 實(shí)例的登錄?)
                  How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道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?)

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

                    1. <legend id='XdviF'><style id='XdviF'><dir id='XdviF'><q id='XdviF'></q></dir></style></legend>

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

                            主站蜘蛛池模板: 国产精品视频一区二区三区不卡 | 欧美激情在线观看一区二区三区 | 在线国产中文字幕 | 99久久精品国产一区二区三区 | k8久久久一区二区三区 | 久久一二 | 欧美成人手机在线 | 天堂一区 | 国产精品免费一区二区三区四区 | 欧美日韩亚洲国产 | 伊久在线 | 一区精品在线观看 | 国产一级特黄aaa大片评分 | 精品欧美乱码久久久久久 | 色综合天天网 | 99精品久久 | 国产精品精品视频一区二区三区 | 六月色婷 | 91成人在线 | 中文字幕三区 | 麻豆一区一区三区四区 | 欧美成人视屏 | 久久成人国产精品 | 免费看黄色小视频 | 伊人色综合久久天天五月婷 | 精品日韩一区二区 | 国产精品视频久久 | 成人免费一区二区三区视频网站 | 国产欧美精品一区二区 | 精品久久久久久 | 免费毛片www com cn | 密桃av| 久久久精品一区二区三区 | 99久久影院 | 亚洲视频中文字幕 | 草久网 | 99成人免费视频 | 国产91丝袜在线播放 | 国产成在线观看免费视频 | 97久久久 | 在线不卡av|