Using square brackets as criteria in a LIKE statement

TUSSFC

Registered User.
Local time
Today, 08:41
Joined
Apr 12, 2007
Messages
57
I need to use square brackets as part of the criteria in a LIKE SQL statement. The criteria is:

[ABC123][SR]

ie, find all records which have that as part of a longer text string. How can I amend the SQL statement below to "escape" the square brackets and treat them as part of the string?

SELECT * FROM p_Overall WHERE (((p_Overall.Assigned_Dept)="ICONS_IMAC")) OR (((p_Overall.Brief_Description) Like '*[ABC123][SR]*'));

Help!!!!

Thanks in advance :-)
 
1) bracket the [ and ] in single quotes

or

2) use the chr() function to embed the character
 
I've simplified the statement to make it easier. Suggestion 1 doesn't work, unless I've messed up:

SELECT * FROM p_Overall WHERE p_Overall.Brief_Description Like '*"["ABC123"]"*';

Also tried & failed with:

SELECT * FROM p_Overall WHERE p_Overall.Brief_Description Like '*'['ABC123']'*';

Not sure how to implement suggestion 2?
 
try concatenateing the '[' to the existing string or concatenate using the chr() function (my preferred way)
 

Users who are viewing this thread

Back
Top Bottom