<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>MySQL Dictionary &#187; Keywords</title>
	<link>http://www.mysqldictionary.com</link>
	<description>A Quick Reference For All Things MySQL</description>
	<pubDate>Tue, 27 Nov 2007 16:19:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>SQL_CALC_FOUND_ROWS</title>
		<link>http://www.mysqldictionary.com/keywords/query-keywords/sql_calc_found_rows</link>
		<comments>http://www.mysqldictionary.com/keywords/query-keywords/sql_calc_found_rows#comments</comments>
		<pubDate>Tue, 13 Nov 2007 05:45:45 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[Query Keywords]]></category>

		<guid isPermaLink="false">http://www.mysqldictionary.com/keywords/query-keywords/sql_calc_found_rows</guid>
		<description><![CDATA[Definition
The SQL_CALC_FOUND_ROWS keyword is used when the result set of a query will be restricted by a LIMIT clause, instructing the MySQL server to store the number of rows that would have been returned had the result set not been restricted. The stored value is exposed through the FOUND_ROWS() function.
Sample
In this example, we first produce [...]]]></description>
			<content:encoded><![CDATA[<h4>Definition</h4>
<p>The <strong>SQL_CALC_FOUND_ROWS</strong> keyword is used when the result set of a query will be restricted by a <strong>LIMIT</strong> clause, instructing the MySQL server to store the number of rows that would have been returned had the result set not been restricted. The stored value is exposed through the <strong>FOUND_ROWS()</strong> function.</p>
<h4>Sample</h4>
<p>In this example, we first produce a list of users, restricted with the LIMIT clause, then we retrieve the full count of users with the FOUND_ROWS() function:</p>
<blockquote>
<pre>
mysql&gt; SELECT SQL_CALC_FOUND_ROWS emailaddress FROM users LIMIT 10,3;
+-----------------------------+
| emailaddress                |
+-----------------------------+
|  ben.@foo.com               |
|  charlie@bar.com            |
|  aaron@baz.com              |
+-----------------------------+
5 rows in set (0.00 sec)mysql&gt;

SELECT FOUND_ROWS();
+--------------+
| FOUND_ROWS() |
+--------------+
|       435136 |
+--------------+
1 row in set (0.00 sec)</pre>
</blockquote>
<h4>Further Reference</h4>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/select.html">SELECT Syntax</a> - MySQL Reference Manual</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows">Found_Rows()</a> - MySQL Reference Manual</p>
<p><a href="http://72.14.253.104/search?q=cache:-GSj-4hVkEwJ:fuzzyblog.com/archives/2006/08/12/sql_calc_found_rows-and-faster-count-alternatives/+SQL_CALC_FOUND_ROWS&amp;hl=en&amp;ct=clnk&amp;cd=6&amp;gl=ca">Google Cache of Article on Improving COUNT(*) Performance</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysqldictionary.com/keywords/query-keywords/sql_calc_found_rows/feed</wfw:commentRss>
		</item>
		<item>
		<title>WITH ROLLUP</title>
		<link>http://www.mysqldictionary.com/keywords/with-rollup</link>
		<comments>http://www.mysqldictionary.com/keywords/with-rollup#comments</comments>
		<pubDate>Tue, 14 Aug 2007 03:18:48 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
		
		<category><![CDATA[Keywords]]></category>

		<category><![CDATA[Query Keywords]]></category>

		<guid isPermaLink="false">http://www.mysqldictionary.com/keywords/with-rollup</guid>
		<description><![CDATA[Definition
The WITH ROLLUP clause is used with GROUP BY queries to generate extra rows in the dataset that represent group totals. Summary rows will show NULL in the group column(s) being summarized. WITH ROLLUP will summarize multiple level of groupings, providing totals across each group level. The WITH ROLLUP clause was added in MySQL 4.1.1.
The [...]]]></description>
			<content:encoded><![CDATA[<h4>Definition</h4>
<p>The <strong>WITH ROLLUP</strong> clause is used with <strong>GROUP BY</strong> queries to generate extra rows in the dataset that represent group totals.<strong> </strong>Summary rows will show <strong>NULL</strong> in the group column(s) being summarized. <strong>WITH ROLLUP</strong> will summarize multiple level of groupings, providing totals across each group level. The <strong>WITH ROLLUP</strong> clause was added in MySQL 4.1.1.</p>
<p>The <strong>WITH ROLLUP</strong> clause cannot be used in a query with an <strong>ORDER BY</strong> clause. Summary columns can be manipulated in the query, allowing for functions like IFNULL() to be used to rename values in summary rows.</p>
<h4>Sample</h4>
<p>In this example, a query is performed to count customers in each city of each country, with summaries on a per-country and global basis. The per-country summary is identified by the presence of a NULL value in the city field, while the global summary is identified by the presence of a NULL value in both the city and country fields.</p>
<blockquote>
<pre>mysql&gt; SELECT country.country, city.city, COUNT(address_id)
-&gt; FROM country LEFT JOIN city USING (country_id)
-&gt; LEFT JOIN address USING (city_id)
-&gt; GROUP by country, city
-&gt; WITH ROLLUP;

| Yugoslavia                            | Kragujevac                 |      1 |
| Yugoslavia                            | Novi Sad                   |      1 |
| Yugoslavia                            | NULL                       |      2 |
| Zambia                                | Kitwe                      |      1 |
| Zambia                                | NULL                       |      1 |
| NULL                                  | NULL                       |    603 |
+---------------------------------------+----------------------------+--------+
710 rows in set (0.00 sec)</pre>
</blockquote>
<h4>Further Reference</h4>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/group-by-modifiers.html" title="GROUP BY Modifiers (MySQL Reference Manual)">GROUP BY Modifiers (MySQL Reference Manual)</a></p>
<p><a href="http://aspnet.4guysfromrolla.com/articles/073003-1.aspx">Summarizing Data with ROLLUP</a></p>
<p><a href="http://databases.about.com/od/sql/l/aacuberollup.htm">Summarizing Data with CUBE and ROLLUP</a></p>
<p><a href="http://aspnet.4guysfromrolla.com/articles/073003-1.aspx"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysqldictionary.com/keywords/with-rollup/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
