ORA 01427 單行子查詢返回多個行

2022-03-27 12:50:26 字數 398 閱讀 8238

問題情境之一的模擬:

select a.sname, b.score, (select c.tel from tab_c c where c.no =

a.no) tel

from

tab_a a, tab_b b

where a.id = b.id

執行指令碼,報錯:ora-01427 單行子查詢返回多個行 

原因:查詢時,要確保每個子查詢只能返回一條資料,

注意:1.針對這種情況,當表a,c關聯時,盡可能將所有的關聯條件都寫上;

2.當報錯的子查詢有重複資料時,嘗試用distinct、max()、分析函式(over()等)等去重

ora-01427: 單行子查詢返回多個行-十字螺絲釘-chinaunix部落格  

單行子查詢返回多行

今天在做專案的時候,將備份back表中的資料更新到正式表中的時候,報了單行子查詢返回多行的錯誤,後來仔細檢視了備份表的子查詢發現確實有多個tcx wx xx id 的記錄,所以rownum 2 強制取了第一條,因為本來就是單條更新。update tcx wx xx wx set tcx sblxzd...

關聯查詢 單行子查詢返回多列

例1 select from table1 where id select id from table1 由於子查詢結果中有多行,但是where條件id 只能有一行記錄 例2 select select name from emp where a.job b.job from emp 由於 子查詢的...

plsql中對單行子查詢返回多個行思考

select a.selcet b.id from b where b.name a.name from aselect a.selcet b.id from b where b.name a.name from a 在plsql介面不報錯,但是展開所有的字段就會報錯 ora 01427 單行子查詢...