This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes mySql like,query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "mySql like,query" Watch "mySql like,query" New topic
Author

mySql like,query

natasa jones
Ranch Hand

Joined: Aug 20, 2006
Posts: 45
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
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

searchTerm is null. Check your code where you call this method, make sure you are setting the value as you expect.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mySql like,query
 
Similar Threads
SQL validation!
HQL query problem
Better sql statement?
hibernate how to make a count and group by
need help in EJB QL with upper and like