• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Sql query to match Strings?

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..

My application is to get a search string from the user and return the records from the database which matches the search string..

I am using LIKE operator in the sql to get matching data..

But my problem is, the matching should be case insensitive..

For example, the data i required may be the Pen..

I have to get this value if i give any of the following possiblities as the search string..
p,pe,pen,PEN,Pen..

please friends help me..

Regards,
Jessica
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Convert both the field value and the search string to the same case (e.g. uppercase):

select your_field from your_table where to_upper(your_other_field) like ....

Convert your search value to uppercase, and append the wildcard character % to it before passing it to the query (e.g. if the user entered pe, you must pass PE%).

Regards, Jan
 
Jessica James
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a Lot ..
Its working fine
 
And then the flying monkeys attacked. My only defense was this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic