简体   繁体   English

需要按RAND排序此SQL结果

[英]Need to sort this SQL result by RAND

I have the following sql and need to sort the results in random order. 我有以下sql,需要按随机顺序对结果进行排序。 I tried adding ORDER BY RAND() but was unsuccessful. 我尝试添加ORDER BY RAND(),但未成功。 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']) .
     ')')));

在PHP中,您可以使用shuffle来对数组进行混洗:

shuffle($items);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM