How To Use LIKE Conditions?
Page 1 of 1
How To Use LIKE Conditions?
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
'_' 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
Similar topics
» How To Use IN Conditions?
» How To Use NULL as Conditions?
» How To Use Regular Expression in Pattern Match Conditions?
» How To Use NULL as Conditions?
» How To Use Regular Expression in Pattern Match Conditions?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Sun Jan 31, 2010 12:35 am by Micheal
» Accessing tables of other users in SQL
Sun Jan 31, 2010 12:34 am by Micheal
» Grouping commands in SQL
Sun Jan 31, 2010 12:32 am by Micheal
» Operations on Result Sets in SQL
Sun Jan 31, 2010 12:31 am by Micheal
» Subqueries in SQL
Sun Jan 31, 2010 12:30 am by Micheal
» Joining Relations in SQL
Sun Jan 31, 2010 12:28 am by Micheal
» Delete comand in SQL
Sun Jan 31, 2010 12:27 am by Micheal
» Update command in SQL
Sun Jan 31, 2010 12:26 am by Micheal
» Insert command in SQL
Sun Jan 31, 2010 12:23 am by Micheal