title: CakePHP model associations - Random order on retrieve of associated model for HABTM
body: <p>I am retrieving data:</p>
  
  <pre><code>$mydata = $this-&gt;ProductList-&gt;find('all', array('order' =&gt; 'rand()', 'conditions' =&gt; array('name' =&gt; 'we love')));
  </code></pre>
  
  <p>I have set up a HABTM relationship to the Product model. As you can see, I am fetching all products in the 'we love'-list. Now, I want those Products I am retrieving to be randomised. But they are not, instead the MySQL is randomised on the ProductList model as you can see in the SQL. Why is that? How can I get the random fetch on the Products instead?</p>
  
  <p>Resulting MySQL query:</p>
  
  <pre><code>SELECT `ProductList`.`id`, `ProductList`.`name` FROM `database`.`product_lists` AS `ProductList` WHERE `name` = 'we love' ORDER BY rand() ASC
  
  SELECT `Product`.`id`, `Product`.`category_id`, `Product`.`name`, `Product`.`price`, `Product`.`description`, `ProductListsProduct`.`product_list_id`, `ProductListsProduct`.`product_id` FROM `database`.`products` AS `Product` JOIN `database`.`product_lists_products` AS `ProductListsProduct` ON (`ProductListsProduct`.`product_list_id` = 3 AND `ProductListsProduct`.`product_id` = `Product`.`id`)
  </code></pre>