• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Problem in Query

 
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
 
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!