<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>mehblog: How to count the number of records in a table...</title>
    <link>http://blog.pauldalton.co.uk/articles/2005/09/28/how-to-count-the-number-of-records-in-a-table</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>random mumblings</description>
    <item>
      <title>How to count the number of records in a table...</title>
      <description>&lt;p&gt;Want to find out how many records there are in a table?&lt;/p&gt;


	&lt;p&gt;You could do a table.&lt;code&gt;&amp;lt;a href="http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000674"&amp;gt;find_by_sql &amp;lt;/a&amp;gt; "select count(*) from table",&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;You could get all the records from the table and then count them, say &lt;code&gt;records = table.find(:all)&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Or&lt;/strong&gt; you could do count = &lt;a href="http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M000683"&gt;table.count&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;How cool is that!&lt;/p&gt;</description>
      <pubDate>Wed, 28 Sep 2005 11:30:55 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:dacd6302f24dbeb25eb2fb22ff576ea8</guid>
      <author>paul</author>
      <link>http://blog.pauldalton.co.uk/articles/2005/09/28/how-to-count-the-number-of-records-in-a-table</link>
      <category>General</category>
      <category>Rails</category>
    </item>
  </channel>
</rss>
