like 表
字段
id
typeid 文章id
userid 用户id
status 赞状态 1:已点赞 0:未点赞
想知道某文章id为1,2,3,4的总赞数,不知道怎么用tp5写
原生sql="select typeid,count(*) from like where typeid in (1,2,3,4) and user_id = 14 and status
=1 group by typeid";
tp5只知道这么写
$ids= '1,2,3,4';
LikeModel::where('typeid','in',$ids)->where(['user_id'=>14,'status'=>1)->group('typeid')->select();
没有用上count(*)
我想实现
typeid count(*)
1 1
2 2
3 2
4 1
慕桂英3389331