How To Use LIKE Conditions in Oracle?
Submitted by: AdministratorLIKE condition is also called pattern patch. There 3 main rules on using LIKE condition:
* '_' is used in the pattern to match any one character.
* '%' is used in the pattern to match any zero or more characters.
* ESCAPE clause is used to provide the escape character in the pattern.
The following script provides you some good pattern matching examples:
SELECT CASE WHEN 'globalguideline.com' LIKE '%Center%'
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
TRUE
SELECT CASE WHEN 'globalguideline.com' LIKE '%CENTER%'
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
-- Case sensitive by default
FALSE
SELECT CASE WHEN 'globalguideline.com' LIKE '%Center_com'
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
TRUE
SELECT CASE WHEN '100% correct' LIKE '100% %' ESCAPE ''
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
TRUE
Submitted by: Administrator
* '_' is used in the pattern to match any one character.
* '%' is used in the pattern to match any zero or more characters.
* ESCAPE clause is used to provide the escape character in the pattern.
The following script provides you some good pattern matching examples:
SELECT CASE WHEN 'globalguideline.com' LIKE '%Center%'
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
TRUE
SELECT CASE WHEN 'globalguideline.com' LIKE '%CENTER%'
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
-- Case sensitive by default
FALSE
SELECT CASE WHEN 'globalguideline.com' LIKE '%Center_com'
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
TRUE
SELECT CASE WHEN '100% correct' LIKE '100% %' ESCAPE ''
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
TRUE
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | What Is Input Buffer in SQL*Plus? |
☺ | How To Write Numeric Literals in Oracle? |
☺ | What Happens to Indexes If You Drop a Table? |
☺ | How To Retrieve Data from an Explicit Cursor? |
☺ | How To Use Values from Other Tables in UPDATE Statements using Oracle? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |