Like criteria ignores "[" character

Happy YN

Registered User.
Local time
Today, 14:33
Joined
Jan 27, 2002
Messages
425
I have some string entries as [Baghdad] (the square brackets are part of the string)
If I query on "[Baghdad]" it finds them
If I use "*baghdad]" it also finds them
BUT if I query using like "[baghdad]" it does not find them
Even stranger if I search on like "*[Baghdad]" it brings up about 70 records which have no connection to Baghdad whatsoever!
All this leads me to conclude that the Like statement cannot be used if the first character is a square bracket so I am asking
a. Is this true?
b. Which other characters does it apply to?
c. What can be done to overcome this?
Thanks
 
The square brackets are used with the Like operator
to search for characters (*, ?, #, [) that have special functionality

e.g. Like "a[*]a" matches a*a, not aaa


or to define a range of characters

e.g. Like "a[b-d]e" matches a, then a letter between b and d, then e.

e.g. Like "a[!b-d]e" matches a, then a letter outside b to d, then e.



Since [ is a special character when used with the Like operator, to search for it using the Like operator, you have to put it in square brackets

e.g. Like "[[]Baghdad]"

e.g. Like "*[[]Baghdad]"
.
 
Last edited:
Thanks ever so much for that explanation Jon. Does that apply to the "]" as well ? Do I have to put that in brackets i.e []] ?
 
No, it doesn't apply to "]". You can search for it as an ordinary character e.g.

Like "*]*"
.
 

Users who are viewing this thread

Back
Top Bottom