aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_record_querying.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-07-14 13:17:01 +0200
committerXavier Noria <fxn@hashref.com>2010-07-14 13:18:07 +0200
commit59945678393b591e263cdee90a8e278a723f93df (patch)
treedafb2c696992f947b74a3b1de50bb338ce7696c1 /railties/guides/source/active_record_querying.textile
parent438bff6ccd0ba495c684a0377fd94cf302e340c5 (diff)
downloadrails-59945678393b591e263cdee90a8e278a723f93df.tar.gz
rails-59945678393b591e263cdee90a8e278a723f93df.tar.bz2
rails-59945678393b591e263cdee90a8e278a723f93df.zip
AR queying guide: let limit and offset be different numbers to help making clear what is what in the explanation, rewords also a bit
Diffstat (limited to 'railties/guides/source/active_record_querying.textile')
-rw-r--r--railties/guides/source/active_record_querying.textile12
1 files changed, 6 insertions, 6 deletions
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile
index 2e23604838..5c4ed3a803 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/railties/guides/source/active_record_querying.textile
@@ -447,28 +447,28 @@ h4. Limit and Offset
To apply +LIMIT+ to the SQL fired by the +Model.find+, you can specify the +LIMIT+ using +limit+ and +offset+ methods on the relation.
-You can use +limit+ to specify the number of records to be retrieved, and use +offset+ to specify the number of records to skip before starting to return the records. For example:
+You can use +limit+ to specify the number of records to be retrieved, and use +offset+ to specify the number of records to skip before starting to return the records. For example
<ruby>
Client.limit(5)
</ruby>
-This code will return a maximum of 5 clients and because it specifies no offset it will return the first 5 clients in the table. The SQL it executes will look like this:
+will return a maximum of 5 clients and because it specifies no offset it will return the first 5 in the table. The SQL it executes looks like this:
<sql>
SELECT * FROM clients LIMIT 5
</sql>
-Or chaining both +limit+ and +offset+:
+Adding +offset+ to that
<ruby>
-Client.limit(5).offset(5)
+Client.limit(5).offset(30)
</ruby>
-This code will return a maximum of 5 clients beginning with the 6th client in the clients table, skipping the first five clients as specified by the offset. The SQL looks like:
+will return instead a maximum of 5 clients beginning with the 31st. The SQL looks like:
<sql>
-SELECT * FROM clients LIMIT 5, 5
+SELECT * FROM clients LIMIT 5, 30
</sql>
h4. Group