Escaping Wildcards in a Like Clause
843833Aug 6 2001 — edited Aug 6 2001Hello,
This might be more of an Oracle question than a JSP question, but I'm going to give it a shot anyway.
I have a field in an Oracle database that I'm trying to do a select statement on from a JSP page. Here's some sample data:
PRO_Test
Testing
Test 3
PROTOCOL
PROFILE_Testing
Another Value
Now here's the problem... I want to be able to filter out all the fields that start with PRO_ and PROFILE from the results. I tried just doing "where Field1 not like 'PRO_%' and Field1 not like 'PROFILE%'" but the underscore is a wildcard, and so the SQL also filters out the values that start with PRO but don't have an underscore. Is there a way to escape the underscore character (using some combination of JSP and SQL) so that this query can work?
Thanks for your help!
David