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

mySql like,query

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!
i would like to know what is the correct syntax for a query which takes as parameter a String and then fetches all the rows which have this String or part of the String!
i use String SQL_Movie_Results="select id from myTable where name like '%"+searchTerm+"%'"; inside my fuction,whose signature is

public List searchByName(String searchTerm)throws Exception.

my problem is that i have tried several different approaches in syntax but i could not put the value of searchTerm betweet %%.it always says :
select id from myTable where name like '%null%'".
what is wrong with my query?
please help:)
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
searchTerm is null. Check your code where you call this method, make sure you are setting the value as you expect.
 
reply
    Bookmark Topic Watch Topic
  • New Topic