久久久久久久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 結構為多個選

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

      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 結構為多個選擇共享一個公共父級的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我嘗試過使用FOR XML PATH"、FOR XML EXPLICIT"和FOR XML AUTO",但數據的結構從來沒有使用正確的層次結構.

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

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

                  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.

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

                  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.

                  實現以下結構的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 為給定客戶創建鏈接"子節點(我將其限制為兩個子表 - 但您應該了解它的要點"并能夠將其擴展到任意數量的鏈接子表):

                  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')
                  

                  給我一??個類似的輸出:

                  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>
                  

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

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

                  相關文檔推薦

                  SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產品、類別和元數據的 SQL 查詢 woocommerce/wordpress)
                  Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數據庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發
                  How to create a login to a SQL Server instance?(如何創建對 SQL Server 實例的登錄?)
                  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()?(為什么會出現“數據類型轉換錯誤?使用 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>

                            主站蜘蛛池模板: 一级毛片免费完整视频 | 国产精品区二区三区日本 | 亚洲一区二区三区四区五区中文 | 国产小视频在线观看 | 国产免费一区二区 | 日本韩国电影免费观看 | 一区二区三区福利视频 | 国产精品视频一二三区 | 91影院在线观看 | 久久毛片 | 亚洲综合在线网 | 黄色在线观看网址 | 亚洲精品日本 | 古装人性做爰av网站 | 天天插天天射天天干 | 久婷婷| 操操日| av日韩在线播放 | 日韩久久久久久 | 中文字幕在线观看 | 成人99| 免费成人av | 亚洲精品久久久久久久久久吃药 | 特黄色毛片 | 日韩欧美三级电影在线观看 | 日韩欧美一区二区在线播放 | 国产一区欧美 | 日韩电影在线一区 | 精品福利一区 | 国产成人一区 | 99精品免费久久久久久日本 | 综合国产 | 午夜三区 | 一区二区三区高清 | 北条麻妃视频在线观看 | 7777精品伊人久久精品影视 | 色又黄又爽网站www久久 | 亚洲一区二区三区在线观看免费 | 亚洲麻豆 | 中文字幕一区二区三 | 日韩欧美一级精品久久 |