如何将查询转换为laravel查询生成器联合

时间:2018-11-07 04:25:03

标签: mysql laravel

我有一个查询和类似的结果

select "URL Listed" as _url, count(url) as total from listings where url != "0" group by 1 union all select "URL Not Listed" as _url, count(url) as total from listings where url = "0" group by 1

,结果是这样enter image description here 。现在我想将其转换为laravel。可能需要一些建议。非常感谢

1 个答案:

答案 0 :(得分:0)

尝试此代码

$urls_details = DB::select("select 'URL Listed' as _url, count(url) as total from listings where url != '0' group by 1 union all select 'URL Not Listed' as _url, count(url) as total from listings where url = '0' group by 1");