wood burning stoves 2.0*
The moose likes JDBC and the fly likes howto get total of rows from mysql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "howto get total of rows from mysql" Watch "howto get total of rows from mysql" New topic
Author

howto get total of rows from mysql

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, how to i get the total of rows in a table, thank you !
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


[ November 23, 2004: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
one more thing i want to add in Paul's reply. that is, if somehow that field, which is mentioned in the count() method, is null, then the whole row would be neglected or would not be counted.

if using oracle better do it this way.

select count(rowid) from table_name
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30353
    
150


This can be used across any database. It eliminates the problem Adeel referred to. It is also easier for the database to optimize.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Alvin chew:
hi, how to i get the total of rows in a table, thank you !


what do you mean Alvin. I got a bit confused after reading Jeanne's reply.
Whether you mean all rows, or total no. of rows?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30353
    
150

Adeel,
Oops! I meant select count(*) from table.

Sorry for the confusion.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: howto get total of rows from mysql