原生语句怎样转为链式语句

浏览:80 发布日期:2022/06/30 分类:求助交流 关键字: sql thinkphp6 模型 Db
$data = Db::query("select *,(select sum(usage_time) from iot_user_usage_record where user_id=a.user_id) times from (select count(1) totalNum,user_id from iot_user_usage_record where user_id in ('1,2,3') GROUP BY user_id order by totalNum desc)a GROUP BY a.user_id");

比如上面的原生语句,请问怎么变成链式,用模型或者Db实现,谢谢了~
最佳答案
评论( 相关
后面还有条评论,点击查看>>