ian
ian

Reputation: 313

Need to sort this SQL result by RAND

I have the following sql and need to sort the results in random order. I tried adding ORDER BY RAND() but was unsuccessful. I may be missing the syntax on it.

$items = Goods_Model_Good::findByCop(array(
       'where' => new JO_Db_Expr(
             'good.id IN (SELECT id
                            FROM good
                            WHERE copId LIKE ' . Helper_Db::quote($cop['copId']) .
     ')')));

Upvotes: 0

Views: 52

Answers (1)

Thorsten Kettner
Thorsten Kettner

Reputation: 95052

In PHP you get an array shuffled with shuffle:

shuffle($items);

Upvotes: 3

Related Questions