• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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
 
Would you like to try a free sample? Today we are featuring tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic