2017-05-25 90 views
-2

我想這個查詢轉換爲Laravel轉換查詢有mysql的

SELECT COUNT(uplineNetworkdetail) AS uplineNetworkdetailCount 
       , idNetworkdetail 
       , uplineNetworkdetail 
       , downlineNetworkdetail 
      FROM networkdetailCommunity where uplineNetworkdetail <>'0' 
      GROUP BY uplineNetworkdetail 
      HAVING uplineNetworkdetailCount = '1' 
      ORDER BY posisi asc 

請幫我該怎麼做?

+2

堆棧溢出不是代碼服務場所 – JYoThI

回答

0

查詢將是:

$query = DB::table('networkdetailCommunity') 
    ->select('DB::RAW(COUNT(uplineNetworkdetail) AS uplineNetworkdetailCount)','idNetworkdetail','uplineNetworkdetail','downlineNetworkdetail') 
    ->where('uplineNetworkdetail','<>','0') 
    ->groupBy('uplineNetworkdetail') 
    ->havingRaw("uplineNetworkdetailCount='1'") 
    ->orderBy('posisi') 
    ->get(); 
+0

TY ..上帝保佑ü –