Oracle中LIKE模糊查詢的使用


Like 模糊查詢
 
占位符
   %  替代一個或多個字符
   _   僅替代一個字符

[charlist] 字符列中的任何單一字符

 

[^charlist] 或者 [!charlist]  不在字符列中的任何單一字符

 


(1)查詢 用戶名以‘S’開頭的員工信息
   Select * from emp where ename like 'S%'

(2)查詢 用戶名以‘S’結尾的員工信息

 Select * from emp where ename like '%S'

(3)查詢用戶名第二個字母是‘A’的員工信息
   select * from emp where ename like '_A%'

(4)查詢用戶名第三個字母是‘A’的員工信息
   select * from emp where ename like '__A%'

(5)查詢用戶名中包含 ‘A’ 的員工信息
   select * from emp where ename like '%A%'

(6)查詢用戶名中不包含 ‘A’ 的員工信息
   select * from emp where ename not like '%A%'

(7)從 "Persons" 表中選取居住的城市"A" 或 "L" 或 "N" 開頭的人:

  SELECT * FROM Persons WHERE City LIKE '[ALN]%'

(8)從 "Persons" 表中選取居住的城市 "A" 或 "L" 或 "N" 開頭的人:

  SELECT * FROM Persons WHERE City LIKE '[!ALN]%'

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM