LIKE Predicate

Description

The LIKE predicate searches for strings that have a certain pattern. The pattern is specified by a string in which the underscore and the percent sign may have special meanings. Trailing blanks in a pattern are part of the pattern.

Click here to navigate to the IBM DB2 docs page for this syntax.

Grammar Syntax

Sample Source Patterns

IBM DB2

insert into like_ex values
    ('John  Dddoe'),
    ('Joe   Doe'),
    ('John_down'),
    ('Joe down'),
    ('Elaine'),
    (''),    -- empty string
    (null);
    
select * from like_ex where subject like '%Jo%oe%';
select * from like_ex where subject like '%J%h%^_do%' escape '^';
select * from like_ex where subject not like 'John%';
select * from like_ex where subject not like '';

Snowflake

select * from like_ex where subject like '%Jo%oe%';
select * from like_ex where subject like '%J%h%^_do%' escape '^';
select * from like_ex where subject not like 'John%';
select * from like_ex where subject not like '';

Last updated

Was this helpful?