Re: Doubt with using "LIKE" clause in sql
Friday, November 22, 2002 07:34 AM
You have to escape all of the 's in your search string. You can do this by either replacing all single 's with 2 ''s or escaping it with an escape character (for example, ). An even easier way is to use a prepared statement for this query, where you replace '%' with ?. Then, after you create your prepared statement, use myPreparedStatement.setString(1,searchString + "%"). This will automatically escape single quotes for you.