<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Ruby on Rails find_by_sql Example</title>
	<atom:link href="http://www.roryhansen.ca/2005/07/01/ruby-on-rails-find_by_sql-example/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.roryhansen.ca/2005/07/01/ruby-on-rails-find_by_sql-example/</link>
	<description>Affiliate marketing, Internet marketing, web development, and small business ideas.</description>
	<lastBuildDate>Tue, 24 Jan 2012 15:37:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: New Ruby</title>
		<link>http://www.roryhansen.ca/2005/07/01/ruby-on-rails-find_by_sql-example/comment-page-1/#comment-92597</link>
		<dc:creator>New Ruby</dc:creator>
		<pubDate>Fri, 17 Sep 2010 08:22:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=14#comment-92597</guid>
		<description>My following code not working, please guide, thanks.

@params[&#039;body&#039;].each do &#124;contact&#124;
  @c = Contact.find(:all, :conditions=&gt; [&quot;contact_id = ?&quot;, contact[&quot;contact_id&quot;]])

  if @c.count &gt; 0
    # update record
  else
    # insert record
  end
end</description>
		<content:encoded><![CDATA[<p>My following code not working, please guide, thanks.</p>
<p>@params['body'].each do |contact|<br />
  @c = Contact.find(:all, :conditions=&gt; ["contact_id = ?", contact["contact_id"]])</p>
<p>  if @c.count &gt; 0<br />
    # update record<br />
  else<br />
    # insert record<br />
  end<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.roryhansen.ca/2005/07/01/ruby-on-rails-find_by_sql-example/comment-page-1/#comment-8025</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 25 Apr 2007 17:11:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=14#comment-8025</guid>
		<description>Or

find :all, :conditions =&gt; [upper(artist_name) like ?&#039;, letter + &quot;%&quot;]

which may or may not be faster, depending on the indexes you have set up.  a like query like this should be able to use a standard index on artist_name, but if you have an index on ucase(left(artist_name)), then Rick&#039;s solution would be faster, probably.</description>
		<content:encoded><![CDATA[<p>Or</p>
<p>find :all, :conditions =&gt; [upper(artist_name) like ?', letter + "%"]</p>
<p>which may or may not be faster, depending on the indexes you have set up.  a like query like this should be able to use a standard index on artist_name, but if you have an index on ucase(left(artist_name)), then Rick&#8217;s solution would be faster, probably.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rick</title>
		<link>http://www.roryhansen.ca/2005/07/01/ruby-on-rails-find_by_sql-example/comment-page-1/#comment-237</link>
		<dc:creator>rick</dc:creator>
		<pubDate>Sat, 03 Jun 2006 21:52:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=14#comment-237</guid>
		<description>find :all, :conditions =&gt; [&#039;ucase(left(artist_name, 1)) = ?&#039;, letter]</description>
		<content:encoded><![CDATA[<p>find :all, :conditions =&gt; ['ucase(left(artist_name, 1)) = ?', letter]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rory on Rails &#187; Ruby on Rails find_all Example</title>
		<link>http://www.roryhansen.ca/2005/07/01/ruby-on-rails-find_by_sql-example/comment-page-1/#comment-4</link>
		<dc:creator>Rory on Rails &#187; Ruby on Rails find_all Example</dc:creator>
		<pubDate>Mon, 04 Jul 2005 04:20:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.roryhansen.ca/?p=14#comment-4</guid>
		<description>[...] 	Recent Posts 			Ruby on Rails find_all ExampleWow! WordPress + My Posts + FireFox == BAD.Ruby on Rails find_by_sql ExampleGet Free [...]</description>
		<content:encoded><![CDATA[<p>[...] 	Recent Posts<br />
 			Ruby on Rails find_all ExampleWow! WordPress + My Posts + FireFox == BAD.Ruby on Rails find_by_sql ExampleGet Free [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

