我使用Query Builder机器laravel进行问题查询
我有疑问:
select count(username) as jumlah
from (select *
from radcheck
group by username
order by username)as counts;
我如何在laravel中创建查询构建器?
我尝试这样做,但与radcheck中的count select *相同。
$posts = DB::table('radcheck')->select(DB::raw('count(username) as jumlah'))
->whereExists(function ($query) {
$query->select('*')
->from('radcheck')
->groupBy('username');
})
->get();
$data= '';
foreach ($posts as $post) {
$data = $post->jumlah;
}
“查询”构建器如何从查询中拉出
select count(username) as jumlah
from (select *
from radcheck
group by username
order by username)as counts;