Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Escaping Wildcards in a Like Clause

843833Aug 6 2001 — edited Aug 6 2001
Hello,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 3 2001
Added on Aug 6 2001
2 comments
429 views