oracle語句查詢or和andSELECT*FROMPersonsWHERE(FirstName='
(FirstName='Thomas' OR FirstName='William') AND LastName='Carter' 會得到 lastname 必須為 carter ,firstname 為 thomas 或者 william的人 thomas carterwilliam carterFirstName='Thomas' OR FirstName='William' AND LastName='Carter' 可以得到 william carter 或者 firstname 為ithomas lastname 不一定是 carter的人 比如:thomas carterwilliam carterthomas king。
oracle語句查詢 or和and
(FirstName='Thomas' OR FirstName='William') AND LastName='Carter' 會得到 lastname 必須為 carter ,firstname 為 thomas 或者 william的人
thomas carter
william carter
FirstName='Thomas' OR FirstName='William' AND LastName='Carter' 可以得到 william carter 或者 firstname 為ithomas lastname 不一定是 carter的人 比如:
thomas carter
william carter
thomas king
在oracle 中,查詢語句用 in 和 or 查詢的結果條數不一樣
先試試不要and a_devtestdt is null 這句、查看兩段代碼結果。
再試試下面
select dept from A
where (status='[D2]方案設計階段' or status='[D2]方案審核中' or status ='[D2]開發中' or status='[D2]開發完成' or status='[D2]單元測試進行中')
and a_devtestdt is null
-----------------------
select dept from A
where status in('[D2]方案設計階段','[D2]方案審核中','[D2]開發中','[D2]開發完成','[D2]單元測試進行中')
and a_devtestdt is null
一般有 OR 和 AND 同時出現的where 條件、最好加括號區分
轉載請注明出處華閱文章網 » oracleor語句