This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

howto get total of rows from mysql

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, how to i get the total of rows in a table, thank you !
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ November 23, 2004: Message edited by: Paul Sturrock ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34084
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This can be used across any database. It eliminates the problem Adeel referred to. It is also easier for the database to optimize.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34084
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adeel,
Oops! I meant select count(*) from table.

Sorry for the confusion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic