mysql查询中的技巧

第一种:
 $res =Db::name('channel')->where('(fenlei=15 AND add_time > '.strtotime("-5 min").')')->fetchSql()->select();

第二种:
 $where = [
                            [
                                ['status','=',2],
                                ['fenlei','=',15],
                                ['account','=',$results[$k]['account']],
                            ],
                            [
                                ['status','=',3],
                                ['fenlei','=',15],
                                ['account','=',$results[$k]['account']],
                            ],
                        ];
                        $m = Db::name('channel')->fieldRaw('SUM(money)')->whereOr($where)->find();

 

posted on 2023-02-07 10:43  kevin_yang123  阅读(16)  评论(0编辑  收藏  举报