Roedy said:
yes, but if you are using LIKE, isn't % one of the things you would
expect?
Why are you using LIKE?
In this case, I don't know; but the OP was using LIKE and worried about
interjected '%' characters. Needed to be pointed out that the common
response (use PreparedStatement) wouldn't solve the problem that the OP
was asking about. I would guess that the OP was using LIKE because of
some other belief about its functionality, such as that is might perform
a case-insensitive comparison (which may even be true with some DBMSs
that do stuff like that; it sounds like the kind of irregular "helpful"
feature you'd find in Access).
In general, though, it's sometimes necessary to find when a given (user
input) string is a substring of a field. In that case, I'd be tempted
to search for wildcard characters ('%' or '_') in the input string
before writing the query. Frankly, I wouldn't know how to deal with it
anyway; is it possible to escape a wildcard character in a LIKE
operator? Every time I've needed to do this, the presence of those
characters represented a validation error, hence I haven't needed to
solve the problem.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation