Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in Query

 
prriya pratheep
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Priya,

Use Trim in the Query itself. It will work..

EX:

trim(' ARVOD TEC ')

You are using Oracle or DB2 ?? :thumb:
 
prriya pratheep
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic