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

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

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

      在 SQL 中的 xml 列中搜索多個值

      Search for multiple values in xml column in SQL(在 SQL 中的 xml 列中搜索多個值)

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

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

                <tbody id='fiJOV'></tbody>
            • <legend id='fiJOV'><style id='fiJOV'><dir id='fiJOV'><q id='fiJOV'></q></dir></style></legend>
                本文介紹了在 SQL 中的 xml 列中搜索多個值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                這是我的桌子

                BasketId(int)   BasketName(varchar) BasketFruits(xml)
                1       Gold        <FRUITS><FID>1</FID><FID>2</FID><FID>3</FID><FID>4</FID><FID>5</FID><FID>6</FID></FRUITS>
                2       Silver      <FRUITS><FID>1</FID><FID>2</FID><FID>3</FID><FID>4</FID></FRUITS>
                3       Bronze      <FRUITS><FID>3</FID><FID>4</FID><FID>5</FID></FRUITS>
                

                我需要搜索具有 FID 值 1 和 3 的籃子所以在這種情況下我會得到

                I need to search for the basket which has FID values 1 and 3 so that in this case i would get Gold and Silver

                雖然我已經達到了可以搜索像 1 這樣的 SINGLE FID 值的結果使用此代碼:

                Although i've reached to the result where i can search for a SINGLE FID value like 1 using this code:

                declare @fruitId varchar(10);
                set @fruitId=1;
                select * from Baskets
                WHERE BasketFruits.exist('//FID/text()[contains(.,sql:variable("@fruitId"))]') = 1
                

                如果是 T-SQL,我會像這樣使用 IN 子句

                HAD it been T-SQL i would have used the IN Clause like this

                SELECT * FROM Baskets where FID in (1,3)
                

                感謝任何幫助/解決方法...

                Any help/workaround appreciated...

                推薦答案

                第一個選項是添加另一個存在的 where 子句.

                First option would be to add another exist the where clause.

                declare @fruitId1 int;
                set @fruitId1=1;
                
                declare @fruitId2 int;
                set @fruitId2=3;
                
                select *
                from @Test
                where
                  BasketFruits.exist('/FRUITS/FID[.=sql:variable("@fruitId1")]')=1 and
                  BasketFruits.exist('/FRUITS/FID[.=sql:variable("@fruitId2")]')=1
                

                另一個版本是在 xquery 語句中使用這兩個變量,計算點擊次數.

                Another version would be to use both variables in the xquery statement, counting the hits.

                select * 
                from @Test
                where BasketFruits.value(
                  'count(distinct-values(/FRUITS/FID[.=(sql:variable("@fruitId1"),sql:variable("@fruitId2"))]))', 'int') = 2
                

                如果您知道在編寫查詢時將使用多少 FID 參數,上面的兩個查詢就可以正常工作.如果您處于 FID 數量不同的情況,您可以使用類似的方法.

                The two queries above will work just fine if you know how many FID parameters you are going to use when you write the query. If you are in a situation where the number of FID's vary you could use something like this instead.

                declare @FIDs xml = '<FID>1</FID><FID>3</FID>'
                
                ;with cteParam(FID) as
                (
                  select T.N.value('.', 'int')
                  from @FIDs.nodes('FID') as T(N)
                )  
                select T.BasketName
                from @Test as T
                  cross apply T.BasketFruits.nodes('/FRUITS/FID') as F(FID)
                  inner join cteParam as p
                    on F.FID.value('.', 'int') = P.FID
                group by T.BasketName
                having count(T.BasketName) = (select count(*) from cteParam)
                 
                

                將@FIDs 變量構建為 XML 以保存要在查詢中使用的值.

                Build the @FIDs variable as an XML to hold the values you want to use in the query.

                您可以在這里測試最后一個查詢:https:///data.stackexchange.com/stackoverflow/q/101600/relational-division-with-xquery

                You can test the last query here: https://data.stackexchange.com/stackoverflow/q/101600/relational-division-with-xquery

                這篇關于在 SQL 中的 xml 列中搜索多個值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                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?)
                WinForms application design - moving documents from SQL Server to file storage(WinForms 應用程序設計——將文檔從 SQL Server 移動到文件存儲)

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

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

                <tfoot id='n0zwA'></tfoot>

                    <tbody id='n0zwA'></tbody>
                    <bdo id='n0zwA'></bdo><ul id='n0zwA'></ul>

                    1. <i id='n0zwA'><tr id='n0zwA'><dt id='n0zwA'><q id='n0zwA'><span id='n0zwA'><b id='n0zwA'><form id='n0zwA'><ins id='n0zwA'></ins><ul id='n0zwA'></ul><sub id='n0zwA'></sub></form><legend id='n0zwA'></legend><bdo id='n0zwA'><pre id='n0zwA'><center id='n0zwA'></center></pre></bdo></b><th id='n0zwA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='n0zwA'><tfoot id='n0zwA'></tfoot><dl id='n0zwA'><fieldset id='n0zwA'></fieldset></dl></div>
                        • 主站蜘蛛池模板: 欧美a区| 看一级黄色毛片 | 亚洲视频在线看 | 中文字幕欧美一区二区 | 午夜精品久久久久久 | 日韩三片| 亚洲小说图片 | 成人国产精品久久 | 成人午夜免费在线视频 | 4hu最新网址 | 日韩av成人| 久久99精品久久久久久国产越南 | 欧美激情一区二区 | 大象视频一区二区 | 国产精品色一区二区三区 | 一区二区三区四区在线 | 午夜电影日韩 | 国产免费又黄又爽又刺激蜜月al | 国精日本亚洲欧州国产中文久久 | 国产高清视频在线 | 国产999精品久久久 午夜天堂精品久久久久 | 7777奇米影视| 欧美成人一区二区三区 | 日本涩涩视频 | 九九综合 | 国产小视频在线观看 | 久久精品久久久久久 | 国产免费一区二区 | 精品国产乱码久久久久久闺蜜 | 午夜免费网站 | 国产成人av免费看 | www.788.com色淫免费 | 亚洲国产成人精品女人久久久 | 欧美一级网站 | 91久久国产综合久久 | 性高湖久久久久久久久3小时 | 成人免费观看男女羞羞视频 | 久久免费观看视频 | 国产日韩欧美精品 | 日韩精品一区二区三区中文在线 | 91麻豆精品国产91久久久更新资源速度超快 |