久久久久久久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 列中搜索多個(gè)值

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

            <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 列中搜索多個(gè)值的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                限時(shí)送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 的籃子所以在這種情況下我會(huì)得到

                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

                雖然我已經(jīng)達(dá)到了可以搜索像 1 這樣的 SINGLE FID 值的結(jié)果使用此代碼:

                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,我會(huì)像這樣使用 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...

                推薦答案

                第一個(gè)選項(xiàng)是添加另一個(gè)存在的 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
                

                另一個(gè)版本是在 xquery 語句中使用這兩個(gè)變量,計(jì)算點(diǎn)擊次數(shù).

                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
                

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

                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 變量構(gòu)建為 XML 以保存要在查詢中使用的值.

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

                您可以在這里測試最后一個(gè)查詢: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

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

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

                相關(guān)文檔推薦

                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?)
                WinForms application design - moving documents from SQL Server to file storage(WinForms 應(yīng)用程序設(shè)計(jì)——將文檔從 SQL Server 移動(dòng)到文件存儲(chǔ))

                <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>
                        • 主站蜘蛛池模板: 久草新视频| 欧美激情99 | 亚洲欧美日韩高清 | 91天堂网| 成人免费网站视频 | 久久精片 | 亚洲高清一区二区三区 | 久久一区精品 | 美女视频网站久久 | 一区二区久久电影 | 欧美精品久久久 | 日韩精品一区二区三区视频播放 | 乳色吐息在线观看 | 国产精品久久久久久一区二区三区 | 国产精品久久久久久久一区二区 | 91综合在线视频 | 操操日 | 99成人 | 99爱免费 | 亚洲一区二区在线 | 欧美日韩在线播放 | 亚洲一区二区日韩 | 九九九久久国产免费 | 中文字幕第三页 | 98久久| 国产精品一区二区在线 | 91av导航 | 最新日韩在线 | 欧美激情精品久久久久久免费 | 国产精品毛片一区二区在线看 | 中文字幕一区二区三区在线乱码 | 亚洲视频在线播放 | 免费成人高清在线视频 | 欧美另类视频在线 | 精品婷婷| 91偷拍精品一区二区三区 | 人人看人人草 | 国产剧情一区 | 91福利电影在线观看 | 久久四虎| 国产亚洲一区二区精品 |