码迷,mamicode.com
首页 > 数据库 > 详细

mysql小技巧 用rand()写随机查询

时间:2015-07-20 12:24:49      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

if ($intelligent_count > 1) {
            //随机抽取推荐菜单
            $intelligent = pdo_fetch("SELECT * FROM " . tablename($this->modulename . ‘_intelligent‘) . " WHERE name=:name AND weid=:weid AND storeid=:storeid AND id<>:id ORDER BY RAND() limit 1", array(‘:name‘ => $num, ‘:weid‘ => $weid, ‘:storeid‘ => $storeid, ‘:id‘ => $intelligentid));
        } else {
            $intelligent = pdo_fetch("SELECT * FROM " . tablename($this->modulename . ‘_intelligent‘) . " WHERE name=:name AND weid=:weid AND storeid=:storeid ORDER BY RAND() limit 1", array(‘:name‘ => $num, ‘:weid‘ => $weid, ‘:storeid‘ => $storeid));
        }

mysql小技巧 用rand()写随机查询

标签:

原文地址:http://www.cnblogs.com/mxiao/p/4660963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!