Posted By: Anonymous
I have an SQL query as below.
Select * from table where name like '%' + search_criteria + '%'
If search_criteria = ‘abc’, it will return data containing
✘✘✘abc✘✘✘x which is fine.
But if my search_criteria = ‘abc%’, it will still return data containing
✘✘✘abc✘✘✘, which should not be the case.
How do I handle this situation?
If you want a
% symbol in
search_criteria to be treated as a literal character rather than as a wildcard, escape it to
... where name like '%' + replace(search_criteria, '%', '[%]') + '%'