File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To Get the Number of Matches Found in the Database

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working a database search by supplying a 'memberName'. There is a field in the data table called 'message_receiver'. I want to count the number if the 'memberName' and the 'messag_receiver' is a match and return the number. How do I do it?
 
Mukesh Netedge
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi JiaPei Jen ,
It seems you need count of the result set returns from the query according to the parameter passed.
Try the following query:
String query = "SELECT count(*****) as countNo FROM message_thread WHERE message_receiver = '" + memberName + "'";
or
String query = "SELECT count(*****) as countNo FROM message_thread WHERE message_receiver like '%" + memberName + "%'";
Then usinf your resultset retrieve the first element as
String noOfMembers=rs.getString("countNo")
Hope it will hepl you.
Mukesh
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic