簡體   English   中英

Laravel 4.2中的子查詢

[英]Sub Query in laravel 4.2

我在laravel下運行以下mysql查詢,但我無法弄清楚該如何實現。

這是MYSQL查詢。

SELECT temp.*,count(temp.respondent_id) FROM (SELECT * FROM `responses` GROUP BY respondent_id) as temp GROUP BY DAY(`temp`.`created_at`)

我正在得到預期的結果。 請幫幫我。 預先感謝您。

嘿,我有解決方法。

作為stachu在評論中給定鏈接“ Solution 1 ”。

&另一種方式如下

$data = \DB::select(\DB::raw('SELECT count(temp.respondent_id) as respondent, DATE(temp.created_at) as date FROM (SELECT * FROM `responses` GROUP BY respondent_id) as temp GROUP BY DAY(`temp`.`created_at`)'));

希望能有所幫助。

嘗試這個,

 $result = DB::select("SELECT temp.*,count(temp.respondent_id) FROM (SELECT * FROM `responses` GROUP BY respondent_id) as temp GROUP BY DAY(`temp`.`created_at`)");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM