Win a copy of Design for the Mind this week in the Design 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: 34178
340
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: 34178
340
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