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

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

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

        <i id='t0cVz'><tr id='t0cVz'><dt id='t0cVz'><q id='t0cVz'><span id='t0cVz'><b id='t0cVz'><form id='t0cVz'><ins id='t0cVz'></ins><ul id='t0cVz'></ul><sub id='t0cVz'></sub></form><legend id='t0cVz'></legend><bdo id='t0cVz'><pre id='t0cVz'><center id='t0cVz'></center></pre></bdo></b><th id='t0cVz'></th></span></q></dt></tr></i><div class="7rjpjzd" id='t0cVz'><tfoot id='t0cVz'></tfoot><dl id='t0cVz'><fieldset id='t0cVz'></fieldset></dl></div>
      1. <tfoot id='t0cVz'></tfoot>
          <bdo id='t0cVz'></bdo><ul id='t0cVz'></ul>
      2. 當(dāng)我們?cè)?SQL Server 2012 中進(jìn)行交叉應(yīng)用和內(nèi)部連接

        When we go for cross apply and when we go for inner join in SQL Server 2012(當(dāng)我們?cè)?SQL Server 2012 中進(jìn)行交叉應(yīng)用和內(nèi)部連接時(shí))

            <tfoot id='YhmfE'></tfoot>
              <tbody id='YhmfE'></tbody>

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

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

                  本文介紹了當(dāng)我們?cè)?SQL Server 2012 中進(jìn)行交叉應(yīng)用和內(nèi)部連接時(shí)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我有一個(gè)關(guān)于 SQL Server 的小問(wèn)題.什么時(shí)候用cross apply,什么時(shí)候用inner join?為什么在 SQL Server 中完全使用 cross apply?

                  I have small question about SQL Server. When do we use cross apply, and when do we use inner join? Why use cross apply at all in SQL Server?

                  我有 emp、dept 表;基于這兩個(gè)表,我編寫了一個(gè) inner joincross apply 查詢,如下所示:

                  I have emp, dept tables; based on those two tables, I write an inner join and cross apply query like this:

                  ----using cross apply
                  SELECT * 
                  FROM Department D 
                  CROSS APPLY 
                      (SELECT * 
                       FROM Employee E 
                       WHERE E.DepartmentID = D.DepartmentID) A 
                  
                  ----using inner join 
                  SELECT * 
                  FROM Department D 
                  INNER JOIN Employee E ON D.DepartmentID = E.DepartmentID 
                  

                  兩個(gè)查詢返回相同的結(jié)果.

                  Both queries return the same result.

                  這里為什么在 SQL Server 中需要 cross apply ?有性能差異嗎?你能告訴我嗎?

                  Here why is cross apply needed in SQL Server? Is there performance difference? Can you please tell me?

                  我們什么時(shí)候使用cross apply,什么時(shí)候使用inner join?這些查詢之間有什么性能差異嗎?請(qǐng)告訴我在 SQL Server 中編寫此查詢的最佳方法是什么.

                  When will we use cross apply and when inner join? Any performance difference between these queries? Please tell me which is the best way to write this query in SQL Server.

                  推薦答案

                  INNER JOINCROSS APPLY(同 LEFT JOINOUTER APPLY) 密切相關(guān).在您的示例中,我假設(shè)引擎會(huì)找到相同的執(zhí)行計(jì)劃.

                  INNER JOIN and CROSS APPLY (same with LEFT JOIN and OUTER APPLY) are very closely related. In your example I'd assume, that the engine will find the same execution plan.

                  • JOIN 是兩個(gè)集合之間的一個(gè)條件鏈接
                  • 一個(gè) APPLY 是一個(gè) row-wise 子調(diào)用
                  • A JOIN is a link between two sets over a condition
                  • an APPLY is a row-wise sub-call

                  但是 - 如上所述 - 優(yōu)化器非常聰明,并且會(huì) - 至少在這種簡(jiǎn)單的情況下 - 理解它歸結(jié)為相同.

                  But - as mentioned above - the optimizer is very smart and will - at least in such easy cases - understand, that it comes down to the same.

                  • JOIN 將嘗試在指定條件下收集子集并將其鏈接
                  • APPLY 將嘗試一遍又一遍地使用當(dāng)前行的值調(diào)用相關(guān)結(jié)果.
                  • The JOIN will try to collect the sub-set and link it over the specified condition
                  • The APPLY will try to call the related result with the current row's values over and over.

                  區(qū)別在于調(diào)用 table-valued-functions(應(yīng)該是 inline-syntax!),與 XML 方法 .nodes()以及更復(fù)雜的場(chǎng)景.

                  Differences are in calling table-valued-functions (should be inline-syntax!), with XML-method .nodes() and with more complex scenarios.

                  ...使用按行計(jì)算的結(jié)果,就像使用變量一樣:

                  ...to use the result of a row-wise calculation like you'd use a variable:

                  DECLARE @dummy TABLE(ID INT IDENTITY, SomeString VARCHAR(100));
                  INSERT INTO @dummy VALUES('Want to split/this at the two/slashes.'),('And/this/also');
                  
                  SELECT d.ID
                        ,d.SomeString
                        ,pos1
                        ,pos2
                        ,LEFT(d.SomeString,pos1-1)
                        ,SUBSTRING(d.SomeString,pos1+1,pos2-pos1-1)
                        ,SUBSTRING(d.SomeString,pos2+1,1000)
                  FROM @dummy AS d
                  CROSS APPLY(SELECT CHARINDEX('/',d.SomeString) AS pos1) AS x
                  CROSS APPLY(SELECT CHARINDEX('/',d.SomeString,x.pos1+1) AS pos2) AS y
                  

                  這與以下內(nèi)容相同,但更易于閱讀(和輸入):

                  This is the same as the following, but much easier to read (and type):

                  SELECT d.ID
                        ,d.SomeString
                        ,LEFT(d.SomeString,CHARINDEX('/',d.SomeString)-1)
                        ,SUBSTRING(d.SomeString,CHARINDEX('/',d.SomeString)+1,CHARINDEX('/',d.SomeString,(CHARINDEX('/',d.SomeString)+1))-(CHARINDEX('/',d.SomeString)+1))
                        ,SUBSTRING(d.SomeString,CHARINDEX('/',d.SomeString,(CHARINDEX('/',d.SomeString)+1))+1,1000)
                  FROM @dummy AS d
                  

                  XML 方法的一個(gè)例子 .nodes()

                  DECLARE @dummy TABLE(SomeXML XML)
                  INSERT INTO @dummy VALUES
                  (N'<root>
                    <a>a1</a>
                    <a>a2</a>
                    <a>a3</a>
                    <b>Here is b!</b>
                  </root>');
                  
                  SELECT All_a_nodes.value(N'.',N'nvarchar(max)')
                  FROM @dummy
                  CROSS APPLY SomeXML.nodes(N'/root/a') AS A(All_a_nodes);
                  

                  結(jié)果

                  a1
                  a2
                  a3
                  

                  一個(gè)內(nèi)聯(lián)函數(shù)調(diào)用的例子

                  CREATE FUNCTION dbo.TestProduceRows(@i INT)
                  RETURNS TABLE
                  AS
                  RETURN
                      SELECT TOP(@i) ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) AS Nr FROM master..spt_values
                  GO
                  
                  CREATE TABLE dbo.TestData(ID INT IDENTITY, SomeString VARCHAR(100),Number INT);
                  INSERT INTO dbo.TestData VALUES
                   ('Show me once',1)
                  ,('Show me twice',2)
                  ,('Me five times!',5);
                  
                  SELECT *
                  FROM TestData
                  CROSS APPLY dbo.TestProduceRows(Number) AS x;
                  
                  GO
                  DROP TABLE dbo.TestData;
                  DROP FUNCTION dbo.TestProduceRows;
                  

                  結(jié)果

                  1   Show me once    1   1
                  2   Show me twice   2   1
                  2   Show me twice   2   2
                  3   Me five times!  5   1
                  3   Me five times!  5   2
                  3   Me five times!  5   3
                  3   Me five times!  5   4
                  3   Me five times!  5   5
                  

                  這篇關(guān)于當(dāng)我們?cè)?SQL Server 2012 中進(jìn)行交叉應(yīng)用和內(nèi)部連接時(shí)的文章就介紹到這了,希望我們推薦的答案對(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)文檔推薦

                  Break down a table to pivot in columns (SQL,PYSPARK)(分解表以按列進(jìn)行透視(SQL、PYSPARK))
                  Spark giving Null Pointer Exception while performing jdbc save(Spark在執(zhí)行jdbc保存時(shí)給出空指針異常)
                  execute query on sqlserver using spark sql(使用 spark sql 在 sqlserver 上執(zhí)行查詢)
                  executeSql failing after putSql processor(putSql處理器后executeSql失敗)
                  How can I compare the one line in one CSV with all lines in another CSV file?(如何將一個(gè) CSV 中的一行與另一個(gè) CSV 文件中的所有行進(jìn)行比較?)
                  How to map the column wise data in flowfile in NiFi?(如何在 NiFi 中映射流文件中的列數(shù)據(jù)?)

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

                          <tfoot id='VIFWr'></tfoot>
                        • <legend id='VIFWr'><style id='VIFWr'><dir id='VIFWr'><q id='VIFWr'></q></dir></style></legend>

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

                            主站蜘蛛池模板: PE拉伸缠绕膜,拉伸缠绕膜厂家,纳米缠绕膜-山东凯祥包装 | 3A别墅漆/3A环保漆_广东美涂士建材股份有限公司【官网】 | 全自动面膜机_面膜折叠机价格_面膜灌装机定制_高速折棉机厂家-深圳市益豪科技有限公司 | 连栋温室大棚建造厂家-智能玻璃温室-薄膜温室_青州市亿诚农业科技 | 北京银联移动POS机办理_收银POS机_智能pos机_刷卡机_收银系统_个人POS机-谷骐科技【官网】 | 电销卡_北京电销卡_包月电话卡-豪付网络| 超细|超微气流粉碎机|气流磨|气流分级机|粉体改性机|磨粉机|粉碎设备-山东埃尔派粉体科技 | 仿古瓦,仿古金属瓦,铝瓦,铜瓦,铝合金瓦-西安东申景观艺术工程有限公司 | 科昊仪器超纯水机系统-可成气相液氮罐-美菱超低温冰箱-西安昊兴生物科技有限公司 | 搪瓷搅拌器,搪玻璃搅拌器,搪玻璃冷凝器_厂家-淄博越宏化工设备 | 车牌识别道闸_停车场收费系统_人脸识别考勤机_速通门闸机_充电桩厂家_中全清茂官网 | 注塑_注塑加工_注塑模具_塑胶模具_注塑加工厂家_深圳环科 | 123悬赏网_发布悬赏任务_广告任务平台| 深圳APP开发_手机软件APP定制外包_小程序开发公司-来科信 | 水性绝缘漆_凡立水_绝缘漆树脂_环保绝缘漆-深圳维特利环保材料有限公司 | 寮步纸箱厂_东莞纸箱厂 _东莞纸箱加工厂-东莞市寮步恒辉纸制品厂 | 楼承板-钢筋楼承板-闭口楼承板-无锡优贝斯楼承板厂 | 陶瓷砂磨机,盘式砂磨机,棒销式砂磨机-无锡市少宏粉体科技有限公司 | 蜗轮丝杆升降机-螺旋升降机-丝杠升降机厂家-润驰传动 | 除湿机|工业除湿机|抽湿器|大型地下室车间仓库吊顶防爆除湿机|抽湿烘干房|新风除湿机|调温/降温除湿机|恒温恒湿机|加湿机-杭州川田电器有限公司 | 消电检公司,消电检价格,北京消电检报告-北京设施检测公司-亿杰(北京)消防工程有限公司 | 武汉印刷厂-不干胶标签印刷厂-武汉不干胶印刷-武汉标签印刷厂-武汉标签制作 - 善进特种标签印刷厂 | 太阳能发电系统-太阳能逆变器,控制器-河北沐天太阳能科技首页 | ★塑料拖链__工程拖链__电缆拖链__钢制拖链 - 【上海闵彬】 | 知网论文检测系统入口_论文查重免费查重_中国知网论文查询_学术不端检测系统 | 综合管廊模具_生态,阶梯护坡模具_检查井模具制造-致宏模具厂家 | 100_150_200_250_300_350_400公斤压力空气压缩机-舰艇航天配套厂家 | 全自动不干胶贴标机_套标机-上海今昂贴标机生产厂家 | 纸张环压仪-纸张平滑度仪-杭州纸邦自动化技术有限公司 | 齿轮减速马达一体式_蜗轮蜗杆减速机配电机-德国BOSERL齿轮减速电动机生产厂家 | 物流之家新闻网-最新物流新闻|物流资讯|物流政策|物流网-匡匡奈斯物流科技 | 河南砖机首页-全自动液压免烧砖机,小型砌块水泥砖机厂家[十年老厂] | 成人纸尿裤,成人尿不湿,成人护理垫-山东康舜日用品有限公司 | 北京翻译公司-专业合同翻译-医学标书翻译收费标准-慕迪灵 | 自动化改造_智虎机器人_灌装机_贴标机-上海圣起包装机械 | 杭州画室_十大画室_白墙画室_杭州美术培训_国美附中培训_附中考前培训_升学率高的画室_美术中考集训美术高考集训基地 | 私人别墅家庭影院系统_家庭影院音响_家庭影院装修设计公司-邦牛影音 | 不发火防静电金属骨料_无机磨石_水泥自流平_修补砂浆厂家「圣威特」 | 西安文都考研官网_西安考研辅导班_考研培训机构_西安在职考研培训 | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | HYDAC过滤器,HYDAC滤芯,现货ATOS油泵,ATOS比例阀-东莞市广联自动化科技有限公司 |