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

為什么這個 sql 使用 union all 沒有返回任何數(shù)據(jù)

why this sql used union all returned no data(為什么這個 sql 使用 union all 沒有返回任何數(shù)據(jù))
本文介紹了為什么這個 sql 使用 union all 沒有返回任何數(shù)據(jù)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

sql 1st 的結(jié)果:

the result of sql 1st:

select p1.t1, p2.t2, p2.t3 from 
(select 'A' as t1,'' as t2,'' as t3 from dual ) p1 left join
(select '' as t1, '' as t2, '' as t3 from dual where 1=2) p2 on p1.t1 = p2.t1

A   NULL    NULL

sql 2nd的結(jié)果:

the result of sql 2nd:

select p1.t1, p2.t2, p2.t3 from 
(select 'B' as t1,'' as t2,'' as t3 from dual ) p1 left join
(select '' as t1, '' as t2, '' as t3 from dual where 1=2) p2 on p1.t1 = p2.t1

B   NULL    NULL

如果我將 sql 的所有這兩個部分聯(lián)合起來,我期望的 sql 是:

if I union all these two part of sql, my expected sql are:

A    NULL    NULL
B    NULL    NULL

但我沒有得到任何結(jié)果.

but I get no result .

sql如下:

select p1.t1, p2.t2, p2.t3 from 
(select 'A' as t1,'' as t2,'' as t3 from dual ) p1 left join
(select '' as t1, '' as t2, '' as t3 from dual where 1=2) p2 on p1.t1 = p2.t1
union all
select p1.t1, p2.t2, p2.t3 from 
(select 'B' as t1,'' as t2,'' as t3 from dual ) p1 left join
(select '' as t1, '' as t2, '' as t3 from dual where 1=2) p2 on p1.t1 = p2.t1

我在 oracle 上測試了這個 sql.我想知道為什么結(jié)果不像我的預(yù)期.順便說一句,如果使用union而不是union all,結(jié)果和預(yù)期的一樣.

I tested this sql on oracle. I want to know why the result is not like my expected. by the way, if use union instead of union all, the result is just like expected.

推薦答案

您還沒有說明您在哪個版本上遇到此問題,但 Gordon Linoff 在運行 11.2.0.2 的 SQL Fiddle 上進(jìn)行了復(fù)制,正如其他人所說它在 10g 和 11.2.0.3 中沒有出現(xiàn),因此認(rèn)為您可能也在 11.2.0.2 上似乎是合理的.

You haven't said which version you're encountering this on, but Gordon Linoff reproduced on SQL Fiddle which is running 11.2.0.2, and as others have said it's not seen in 10g and 11.2.0.3, so it seems reasonable to think you might be on 11.2.0.2 as well.

在這種情況下,這看起來與錯誤 12336962 相同.如果您可以訪問 Oracle 支持,您(或您的 DBA)可以查看它,但我無法重現(xiàn)它在這里所說的內(nèi)容,即使它是一個已發(fā)布的錯誤.運行您的查詢和錯誤報告中的示例會產(chǎn)生相同的結(jié)果,并且在兩種情況下從 union all 更改為 union 都會產(chǎn)生正確的結(jié)果.不過,您可能想要提出服務(wù)請求以確認(rèn)這一點.

In which case, this looks identical to bug 12336962. If you have access to Oracle Support you (or your DBA) can look that up, but I can't reproduce what it says here, even though it's a published bug. Running your query and the example from the bug report produce the same results, and in both cases changing from union all to union produces correct results. You might want to raise a service request to get that confirmed though.

該錯誤已在 11.2.0.3 補丁集中修復(fù) - 我不確定我是否真的應(yīng)該分享它,但它已經(jīng)在這里發(fā)布 - 所以修補可能是你最好的選擇,如果你提出 SR,Oracle 可能會建議你這樣做.如有疑問,請直接詢問 Oracle.

That bug is fixed in the 11.2.0.3 patch set - I'm not sure I'm really supposed to even share that, but it's already published here - so patching up might be your best bet, and Oracle might suggest that if you do raise an SR. If in doubt, ask Oracle directly.

這篇關(guān)于為什么這個 sql 使用 union all 沒有返回任何數(shù)據(jù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

What SQL Server Datatype Should I Use To Store A Byte[](我應(yīng)該使用什么 SQL Server 數(shù)據(jù)類型來存儲字節(jié) [])
Interpreting type codes in sys.objects in SQL Server(解釋 SQL Server 中 sys.objects 中的類型代碼)
Typeorm Does not return all data(Typeorm 不返回所有數(shù)據(jù))
Typeorm .loadRelationCountAndMap returns zeros(Typeorm .loadRelationCountAndMap 返回零)
How to convert #39;2016-07-01 01:12:22 PM#39; to #39;2016-07-01 13:12:22#39; hour format?(如何將“2016-07-01 01:12:22 PM轉(zhuǎn)換為“2016-07-01 13:12:22小時格式?)
MS SQL: Should ISDATE() Return quot;1quot; when Cannot Cast as Date?(MS SQL:ISDATE() 是否應(yīng)該返回“1?什么時候不能投射為日期?)
主站蜘蛛池模板: 国产精品免费人成网站酒店 | 日日夜夜干 | 91蜜桃在线观看 | 国产视频www | 久久日韩精品 | 日韩国产精品一区二区 | 天天干天天草 | 国产精品视频免费 | 国产成人精品一区 | 日本a视频 | 久久久一级片 | 婷婷综合 | 亚洲免费视频一区 | 国产欧美日韩在线观看 | 中文字幕精品视频 | 亚洲精品在线看 | 黄色免费一级片 | 欧美精品在线免费观看 | 特级毛片爽www免费版 | 日韩视频在线免费观看 | 成年人视频在线播放 | 国产伦精品一区二区三区四区 | 久久精品国产免费 | 免费av在线 | 99中文字幕 | 嫩草嫩草嫩草嫩草 | 午夜激情在线观看 | 久久久久国产视频 | 欧美精品久久99 | 欧美日韩第一区 | 黄色大片在线 | 中文字幕亚洲综合 | 亚洲综合激情网 | 久久精品亚洲 | 成人在线免费观看视频 | 欧美一区二区三区在线视频 | 日本一本视频 | 国产欧美日韩在线 | 欧美高清在线 | 久久久久成人网 | 久久久国产一区二区三区 |