• 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
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Retrieving Count (*) value

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everyone,
Here is my problem. I have a table and I m interested in finding the number of rows from a select statement.
SELECT COUNT(EMPID) FROM EMPLOYEE WHERE DEPARTMENT = 'HR';
After I execute the query I don't know how to retrieve the integer value. I used ResultSet.getInt(integer) but it doesn't help. Any idea on how to get the count value. Appreciate your response. Thanks,
Param
 
Param Yanamandra
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I figured it out. ResultSet.getInt(1) since the result set has only one column containing the Count(Empid) value.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u can use
resultset.getInt("COUNT(EMPID)")
or
resultset.getInt(1); according to your query
 
Aamir Iqbal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u can use
resultset.getInt("COUNT(EMPID)")
or
resultset.getInt(1); according to your query
 
Looky! I'm being abducted by space aliens! Me and this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic