i need to search for and of these ! @ # $ % ^ & * ( ) '\ symbols in within a field content sqlite database, i am using the following sql string
Select ID From Tasks Where '--' || tasks || '--' || note || '--' like '%! @ # $ % ^ & * ( ) ""%'
or i tried this
Select ID From Tasks Where task LIKE '[!] [@] [#] [$] [%] [^] [&] [*] [(] [)] ''%'
but the search does not return any result. For the field task some of the content are
-
Today's tasksor -
here are some wildcards ! @ # $ % ^ & * ( ) 'or -
Some brakest are [ ] { } ( )
so if i search item one as a whole, i should get it or if i search for ! @ # $ % ^ & * ( ) ', i should get item 2. etc
if i serah within the field passing some of the wildcards within the text or all in the same order, i should get the row contain the value
I know some of the symbols have meaning in sqlite sql, so how do i escape all or any of these characters in an sql query string
First, strings in SQL are enclosed in single quotes; if you want to write a string containing single quotes, you have to escape them by doubling them:
To avoid this, most languages allow you to use parameters:
Second, the
LIKEoperator interprets the%and_characters specially.To use these characters without their special meaning, you can use the
ESCAPEclause to specify a character that escapes%,_, and itself:This escaping is completely independent from the SQL string quoting; you stil you have to use even if you’re using parameters:
Third, the
GLOBoperator does not have special escape characters;you use special characters literally, you have to use them in peculiar ways.
From the documentation: