This content has been marked as final. Show 7 replies
Edit - Scratch that idea. It doesn't appear to work exactly as it should.
oops... yeah that didn't work.
You suggested using double brackets [[ ]].
I think the solution lies in using ESCAPE '\' but for some reason it doesn't like that combination of \ and [ ]
I didn't test it extensively but it seemed like the matches weren't quite correct. For instance if #UserID# = 99 I think the query results included
Test record 1: [User:99] ....blah
Test record 2: [User:9999] ....blah
Test record 3: [User:999]....blah
But it should only have included record 1. Then again maybe my brain was tired ;-)
You are correct. If you leave the brackets in the LIKE statement, it will return results as if the brackets weren't there at all.
Perhaps I need to figure out the ASCII character value of the bracket and include it that way i.e. #Char(?)# where the question mark would be the numerical value of that character.
My temporary solution has been to leave off the starting bracket:
<cfquery dbtype="query" name="getLogs">
WHERE Description LIKE '%user:#UserID#]%'
This has (so far) returned the results i'm looking for although its not as 100% accurate without that beginning [ in the LIKE statement.
Edit - Duh. Yes square brackets [ ] are used to indicate a range of characters. That's why the results aren't quite what you'd expect.
"Square brackets ([ ]) represents any character in the range."
What about this?
WHERE Description LIKE '%[User:#UserID#]%'
Thats the trick! The '[' method worked. Here is the final LIKE statement: Description LIKE '%[user:#UserID#]%'