0

SQL语句如下:
select * from lg_poster a join (select (hash) from lg_poster where status='publish' order by last_reply_time desc limit 20 offset 0) b on a.hash = b.hash

2019-03-20 提问
1 个回答
0

这种又子查询 又有join 我选择直接sql

DB::select($sql); //当然这层放repostory 我们这操作db model放这层

我之前也没找到 答案

如果只有join我是这么用


$orders = Order_goods::select(['t_orders.order_id','t_orders.origin_price','t_orders.service_price','t_order_goods.buy_id',
            't_orders.created_at','t_orders.payment_price','t_orders.paying','t_order_goods.goods_price','t_order_goods.goods_num',
            't_shop_goods.title','t_shop_goods.shop_site','t_shop_goods.shop_type','t_shop_goods.tech_retreat','t_shop_goods.custom_price',
            't_shop_goods.tech_price','t_shop_goods.subject_cate_id','t_shop_goods.tech_retreat','t_orders.sell_price'])
            ->join('t_orders','t_order_goods.order_id','=','t_orders.order_id')
            ->join('t_shop_goods','t_order_goods.goods_id','=','t_shop_goods.id')
            ->where('t_order_goods.id',$id)
            ->first();

撰写答案

推广链接