Webmaster Forum
Go Back   Webmaster forum » ..:: Web Design ::.. » Programin Language

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2009
pali pali is offline
Senior Member
 
Join Date: Jul 2009
Posts: 318
iTrader: (0)
pali is on a distinguished road
Talking How to determine the number of rows in the full result set and also restrict the numb

How to determine the number of rows in the full result set and also restrict the number of rows that a query returns,without running a second query ?

Most of the developers using 2 queries to find total number of rows and limit,when
we need pagination(1,2,3,4). why should we write 2 queries to find limit as well as total number of rows in a table.

we can achieve this in a single query.

eg:
SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name
WHERE id > 567 LIMIT 10;

So SQL_CALC_FOUND_ROWS can be useful in situations when you want to restrict the number of rows that a query returns, but also determine the number of rows in the full result set without running the query again.
__________________
website worth calculator
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:42 PM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.