dcsimg
Doubt with using "LIKE" clause in sql
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhishek_Deb
Posted On:   Friday, November 22, 2002 12:32 AM

Hello
can u help me out in this issue.
i am trying to make a simple search. For that i am usin the querry which uses the like clause.

But the problem is the system bombs whenever i enter the charector ' as my search because my querry which goes like this does not recognize.....please help

SELECT IPM_ACTIVITY_NAME FROM TBL_IMPROVEMENT_PLAN_MASTER WHERE IPM_ACTIVITY_NAME LIKE '%'


so now if i search for a charector starting with ' how do i do that please help me.

Re: Doubt with using "LIKE" clause in sql

Posted By:   Jeff_Hubbach  
Posted On:   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.
About | Sitemap | Contact