데이터베이스/Oracle

Oracle 와일드카드

왕왕왕왕 2015. 11. 7. 10:09

% A substitute for zero or more characters
_ A substitute for a single character
[charlist] Sets and ranges of characters to match
[^charlist]
or
[!charlist]
Matches only a character NOT specified within the brackets

 

 

 

// Table에 컬럼명이 king으로시작하는 문자열

SELECT * FROM Table WHERE Column LIKE 'king%';

 

// in이라는 문자를 포함한 글자

SELECT * FROM Table WHERE Column LIKE '%in%';

 

// 문자열이 ing로끝나면서 앞에 어떤 글씨가 있는 경우

SELECT * FROM Table WHERE Column LIKE '_ing';

 

// k로 시작하고 중간에 i가있고 ng로 끝나는 문자열

SELECT * FROM Table WHERE Column LIKE 'k_i_ng;

 

// 'a'나 'c'또는 't'로 시작하는 문자열 apple,cancle,target 등등

SELECT * FROM Table WHERE Column LIKE '[act]%';

 

// 'a'나 'c'또는 't'로 시작하지않는 문자열들

SELECT * FROM Table WHERE Column LIKE '[!act]%';

or

SELECT * FROM Table WHERE Column NOT LIKE '[act]%';