<?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: Complex SQL Sorts with Rails/ActiveRecord</title>
	<atom:link href="http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/feed/" rel="self" type="application/rss+xml" />
	<link>http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/</link>
	<description></description>
	<lastBuildDate>Mon, 26 Nov 2007 10:17:44 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Sudden</title>
		<link>http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/comment-page-1/#comment-16982</link>
		<dc:creator>Sudden</dc:creator>
		<pubDate>Sat, 20 Oct 2007 13:56:20 +0000</pubDate>
		<guid isPermaLink="false">http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/#comment-16982</guid>
		<description>:group =&gt; &quot;&#039;a&#039;&quot; (String &#039;a&#039;) makes sure, that all found rows are grouped together</description>
		<content:encoded><![CDATA[<p>:group =&gt; &#8220;&#8216;a&#8217;&#8221; (String &#8216;a&#8217;) makes sure, that all found rows are grouped together</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sudden</title>
		<link>http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/comment-page-1/#comment-16981</link>
		<dc:creator>Sudden</dc:creator>
		<pubDate>Sat, 20 Oct 2007 13:54:57 +0000</pubDate>
		<guid isPermaLink="false">http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/#comment-16981</guid>
		<description>Try

r = Restaurant.find(:all,
                     :select =&gt; &#039;group_concat(id) as ids&#039;,
                     :group =&gt; &quot;&#039;a&#039;&quot;,
                     :order =&gt; :popularity,
                     :limit =&gt; 100)

to get the already comma-separated ID-list returned by the mysql-server.
r[:ids] then contains that string.

You need to make sure mysqls group_concat_max_len is large enough.</description>
		<content:encoded><![CDATA[<p>Try</p>
<p>r = Restaurant.find(:all,<br />
                     :select =&gt; &#8216;group_concat(id) as ids&#8217;,<br />
                     :group =&gt; &#8220;&#8216;a&#8217;&#8221;,<br />
                     :order =&gt; :popularity,<br />
                     :limit =&gt; 100)</p>
<p>to get the already comma-separated ID-list returned by the mysql-server.<br />
r[:ids] then contains that string.</p>
<p>You need to make sure mysqls group_concat_max_len is large enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arrix</title>
		<link>http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/comment-page-1/#comment-4521</link>
		<dc:creator>Arrix</dc:creator>
		<pubDate>Sun, 29 Apr 2007 03:53:45 +0000</pubDate>
		<guid isPermaLink="false">http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/#comment-4521</guid>
		<description>You may want to use select_values() so that you don&#039;t need to map.</description>
		<content:encoded><![CDATA[<p>You may want to use select_values() so that you don&#8217;t need to map.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
