Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

find out total number of rows in query Mysql

find out total number of rows in query Mysql

 
Post new topic   Reply to topic     Forum Index -> DataBase, RDBMS, MySql, Oracle, db2, SQL Server problems
View previous topic :: View next topic  
Author Message
abington



Joined: 08 Dec 2008
Posts: 2

PostPosted: Wed Dec 17, 2008 4:51 pm    Post subject: find out total number of rows in query Mysql Reply with quote

Hi
In Mysql database query, I am using limit function for pagination purpose. In this condition, 10 rows fetching each time. Problem is now, I have to use again same as sub query without limit function to count number of rows in query table.
Back to top
View user's profile Send private message
wangmu



Joined: 08 Dec 2008
Posts: 4

PostPosted: Wed Dec 24, 2008 7:12 am    Post subject: Reply with quote

Total number of rows in mysql


Code:
mysql> SELECT SQL_CALC_FOUND_ROWS * FROM table_name LIMIT 10;

mysql>SELECT FOUND_ROWS();


This will return total rows in first query
Back to top
View user's profile Send private message
LOBSANG



Joined: 08 Dec 2008
Posts: 2

PostPosted: Wed Dec 24, 2008 9:55 am    Post subject: Reply with quote

count also can give you total number of rows in sql

I use to execute subquery in query

this also give me total number of rows

Code:
SELECT column1, column2, (SELECT count(*) FROM table_name) as cnt FROM table_name a limit 10;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DataBase, RDBMS, MySql, Oracle, db2, SQL Server problems All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack