oracle資料庫有關於子查詢

2021-10-01 11:26:34 字數 810 閱讀 4278

a.有關於in

在最基本的查詢之中,已經提到,並不是連續的查詢,注意與between…and…區分

select 屬性1,屬性2… from 表1 where 主鍵/外來鍵 in(select 外來鍵、主鍵 from 表2 where 限制條件);

會將in裡面所有的條件當做限制條件查詢

b.有關於any

any的意思滿足任意乙個就可以

select 屬性1,屬性2… from 表1 where 主鍵/外來鍵 運算子 any(select 外來鍵、主鍵 from 表2 where 限制條件);

舉個例子:select nnum,nname from op1 where nnum > any(select nnum from op2 where mnun>『121』);

例子解釋:在子查詢中查詢出滿足mnum>121的nnum,

在外查詢中nnum 只要大於子查詢中的nnum任意乙個就可以輸出op1查詢的nnum和nname。

c.有關於all

all 的意思是滿足所有的才可以

select 屬性1,屬性2… from 表1 where 主鍵/外來鍵 運算子 all(select 外來鍵、主鍵 from 表2 where 限制條件);

舉個例子:

舉個例子:select nnum,nname from op1 where nnum > all(select nnum from op2 where mnun>『121』);

例子解釋:在子查詢中查詢出滿足mnum>121的nnum,

在外查詢中nnum 必須大於子查詢中的nnum所有才可以輸出op1查詢的nnum和nname。

資料庫oracle學習心得有關於多表查詢

資料庫oracle學習心得有關於多表查詢 資料庫中的多表查詢分為兩種 內連線和外連線 內連線與外連線的區別 就是外連線比內連線多了乙個left或者right 查詢結構 下面詳細講講有關於內連線與外連線 內連線 查詢的結構 select 表1.表1的屬性,表2.表2的屬性 from 表1 join 表...

Oracle資料庫關於分頁查詢

今天寫專案,碰巧寫到分頁我用的oracle資料庫 剛開始沒注意用的還是mysql的分頁方式 limit關鍵字 剛執行就發現不對勁後來改為oracle資料庫的rownum,比mysql要複雜一些 如下 查詢0到10的資料 select from select rownum rn t.from sele...

資料庫子查詢

概念 當乙個查詢是另乙個查詢的條件時,這個查詢稱之為子查詢 內層查詢 主要有以下三種表現形式 1.select 列 from 子查詢 2.select 列 from 表 where 列 比較運算子 子查詢 3.select 列 from 表 left join 子查詢 left join 子查詢 字...