--把tableA 中sign值为package 赋值给tableB update b set b.sign=a.sign from tableA a,tableB b where a.order_id=b.order_id and a.sign='package' --统计数量 select count(*) as 数量 from tableB where sign='package'
你可以使用withCount()方法试一下
$posts = Post::withCount(['votes', 'comments' => function ($query) {
$query->where('content', 'like', 'foo%');}])->get();
}])->get()