SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Dec 30, 2004, 08:32 #1
how to look for wildcards in the database
Hello
I know that the % and _ wildcards can be used in conjunction with LIKE to perform powerful queries.
I would like to be able to look for these letters as part of my query though.
For example, If I look for the letter %, then the entry '5%' should be found.
Similarly for the letter _
if I look for _ then it should find the entry 'an underscore is _'
Can anyone tell me how I can escape these special wildcards in my search?
regards
-
Dec 30, 2004, 08:35 #2
- Join Date
- Mar 2003
- Location
- England, UK
- Posts
- 2,906
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You have to use the escape character like so:
\_ or \%
-
Dec 30, 2004, 08:39 #3
so if I look for:
%\%%
it will find anything that contains a '%' ?
-
Dec 30, 2004, 09:56 #4
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
find an underscore --
... where foo like '%^_%' escape '^'
find a percent sign --
... where foo like '%?%%' escape '?'
Bookmarks