Okay, I cannot figure out why the following code doesn't work as planned:
SELECT * FROM T_CONTRIBUTION WHERE NOTES LIKE '%[Anonymous gift]%'
For some reason, that command pulls records with all kinds of things in NOTES, but not the phrase I asked for. Is there some SQL syntax that the [ character signifies when used with the % wildcard? There should only be two records with [Anonymous gift] in the notes field, yet I get over 8500 records returned by the aforementioned command. WTH?
Thank you in advance for any help you may provide.
BONUS RAINY DAY TRIVIA: A rainbow can occur only when the sun is 40 degrees or less above the horizon.
Yeah, if you put things in square brackets, it thinks you are listing a list of characters that you could be looking for. So it's returning anything with any of the letters in "anonymous gift" in it.
From the SQL help:
Use the ESCAPE keyword to define an escape character. When the escape character is placed in front of the wildcard in the pattern, the wildcard is interpreted as a character. For example, to search for the string 5% anywhere in a string, use:
WHERE ColumnA LIKE '%5/%%' ESCAPE '/'
In this LIKE clause, the leading and ending percent signs (%) are interpreted as wildcards, and the percent sign preceded by a slash (/) is interpreted as the % character.
So for yours you would do... where notes like '%/[anonymous gift/]%' escape '/'