我想将此查询转换为Laravel
SELECT COUNT(uplineNetworkdetail) AS uplineNetworkdetailCount
, idNetworkdetail
, uplineNetworkdetail
, downlineNetworkdetail
FROM networkdetailCommunity where uplineNetworkdetail <>'0'
GROUP BY uplineNetworkdetail
HAVING uplineNetworkdetailCount = '1'
ORDER BY posisi asc
请帮我怎么做?
答案 0 :(得分: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();