<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ModeWeb Blog &#187; MySQL</title>
	<atom:link href="http://www.modeweb.co.uk/blog/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.modeweb.co.uk/blog</link>
	<description>Web Development Tech Blog</description>
	<lastBuildDate>Sun, 25 Dec 2011 22:05:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MySQL Count Rows For Pagination</title>
		<link>http://www.modeweb.co.uk/blog/2011/12/mysql-count-rows-for-pagination/</link>
		<comments>http://www.modeweb.co.uk/blog/2011/12/mysql-count-rows-for-pagination/#comments</comments>
		<pubDate>Sun, 25 Dec 2011 21:36:46 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.modeweb.co.uk/blog/2011/12/mysql-count-rows-for-pagination/</guid>
		<description><![CDATA[The following SQL snippet shows a neat way to do queries when implementing paged results.
I have tested the snippet on MySQL 5 only.

SELECT SQL_COUNT ROWS *, tableName.id, tableName.someCol
FROM tableName
LIMIT 0,25;



SELECT SELECT FOUND_ROWS();

For example, say the above table tableName has a total of 100 rows, running the above queries one after another would first return a [...]]]></description>
			<content:encoded><![CDATA[<p>The following SQL snippet shows a neat way to do queries when implementing paged results.</p>
<p>I have tested the snippet on MySQL 5 only.</p>
<pre>
SELECT SQL_COUNT ROWS *, tableName.id, tableName.someCol
FROM tableName
LIMIT 0,25;
</pre>
<p><span id="more-147"></span></p>
<pre>
SELECT SELECT FOUND_ROWS();
</pre>
<p>For example, say the above table <code>tableName</code> has a total of 100 rows, running the above queries one after another would first return a result set of 25 rows, then the second query would return 100, the total number of rows.</p>
<p>It may be interesting also to see if there is a performance difference between a   3 or a 2 query approach, as the MySQL manual only shows running the <code>SQL_COUNT_ROWS *</code> statement on it&#8217;s own, unlike with columns as I have done here.</p>
<p>My hunch is that 2 queries would be faster but maybe not for tables with millions of rows?</p>
<p>
<a href="http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows">http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.modeweb.co.uk/blog/2011/12/mysql-count-rows-for-pagination/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

