SQLite Forum

ESCAPE '%'
Login
Hi,

    sqlite> CREATE TEMP TABLE Test (text TEXT);
    sqlite> INSERT INTO Test VALUES ('100%');
    sqlite> INSERT INTO Test VALUES ('100 percent');
    sqlite> SELECT text FROM Test WHERE text LIKE '100%';
    100%
    100 percent
    sqlite> SELECT text FROM Test WHERE text LIKE '100x%' ESCAPE 'x';
    100%

So far, so good.

    sqlite> SELECT text FROM Test WHERE text LIKE '100%%' ESCAPE '%';
    100%
    100 percent

Is this expected behavior? The docs say:

> If the optional ESCAPE clause is present, then the expression following the ESCAPE keyword must evaluate to a string consisting of a single character. This character may be used in the LIKE pattern to include literal percent or underscore characters. The escape character followed by a percent symbol (%), underscore (_), or a second instance of the escape character itself matches a literal percent symbol, underscore, or a single escape character, respectively.

Can a percent character not be used as an escape character?

Thanks,
Hamish