| Author |
Problem in Query
|
prriya pratheep
Greenhorn
Joined: Jun 10, 2008
Posts: 22
|
|
Hi friends, I want to do one jdbc program which runs the query with wild characters. Before that in my table filed values are like "ARVOD TEC ", that is a lot of space at the end. In jsp page if the user enter AR* it should display all the data starts with AR if the user enter *VOD it should display all the data ends with vod. I wrote the code to check if the * is at last.In this code strmpn contains is field value for (int i=0; i < strmpn.length(); i++) if (strmpn.charAt(i)=='*') { flag = true; } String replaces =strmpn.replace('*','%'); if (flag) Query = Query +" MPN like '"+replaces +"'"; else Query = Query +" MPN = '"+replaces +"'"; If the * is at the end it is working fine. What is my problem is i want to check at the begining too Since field values contains lot of space at the end , for example "ARC ",I am not able to get the result... Please help me how to solve this problem... Thanks & Regards
|
 |
Casttro Francis
Greenhorn
Joined: Oct 08, 2008
Posts: 25
|
|
HI Priya, Use Trim in the Query itself. It will work.. EX: trim(' ARVOD TEC ') You are using Oracle or DB2 ?? :thumb:
|
Any fool can write code that a computer can understand. Good programmers write code that humans can understand....
|
 |
prriya pratheep
Greenhorn
Joined: Jun 10, 2008
Posts: 22
|
|
I am using MYSQL... I am using select st and display the value(this is for search form) My code is Thanks for the reply Thanks and Regards
|
 |
 |
|
|
subject: Problem in Query
|
|
|