Oracle SQL - How To Use LIKE Conditions
Interview Question Database For Software Developers
|
|
| How To Use LIKE Conditions | | How To Use LIKE Conditions? - Oracle DBA FAQ - Understanding SQL Basics | | By: FYIcenter.com | LIKE 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 'FYICenter.com' LIKE '%Center%'
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
TRUE
SELECT CASE WHEN 'FYICenter.com' LIKE '%CENTER%'
THEN 'TRUE' ELSE 'FALSE' END FROM DUAL;
-- Case sensitive by default
FALSE
SELECT CASE WHEN 'FYICenter.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
| | ID: 826 | Rank: 1075 | Votes: 0 | Views: 28 | Submitted: 20070423 |
1070 :-) | | What Are DDL Statements | | What Are DDL Statements? - Oracle DBA FAQ - Understanding SQL DDL Statements... | | Submitted: 20070422 |
|
Copyright © 2009 FYIcenter.com
All rights in the contents of this Website are reserved by the individual author.
No part of the contents may be reproduced in any form without author's permission.
|
|
|