<?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:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Complex SQL Sorts with Rails/ActiveRecord</title>
	<link>http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/</link>
	<description></description>
	<pubDate>Fri, 29 Aug 2008 05:56:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Sudden</title>
		<link>http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/#comment-16982</link>
		<dc:creator>Sudden</dc:creator>
		<pubDate>Sat, 20 Oct 2007 13:56:20 +0000</pubDate>
		<guid>http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/#comment-16982</guid>
		<description>:group =&#62; "'a'" (String 'a') 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-16981</link>
		<dc:creator>Sudden</dc:creator>
		<pubDate>Sat, 20 Oct 2007 13:54:57 +0000</pubDate>
		<guid>http://gurge.com/blog/2006/11/18/complex-sql-sorts-with-railsactiverecord/#comment-16981</guid>
		<description>Try

r = Restaurant.find(:all,
                     :select =&#62; 'group_concat(id) as ids',
                     :group =&#62; "'a'",
                     :order =&#62; :popularity,
                     :limit =&#62; 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-4521</link>
		<dc:creator>Arrix</dc:creator>
		<pubDate>Sun, 29 Apr 2007 03:53:45 +0000</pubDate>
		<guid>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'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>
