• 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

To Get the Number of Matches Found in the Database

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic