第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

sql查詢到laravel查詢與聯(lián)合

sql查詢到laravel查詢與聯(lián)合

PHP
月關(guān)寶盒 2023-05-12 15:11:54
我想將下面的聯(lián)合查詢轉(zhuǎn)換為 laravel 查詢DB::select("select lead_master.lead_stage from lead_master inner join  user_master on user_master.user_name=lead_master.assigned_user_name where region in (".$geo_string.") and teams in (".$filter_teams_string.") group by (lead_stage) unionselect  meeting_hash from meetings_master where assigned_user_name in (".$filter_username_string.") and meeting_hash in ('follow_up','first_time') group by (meeting_hash)  union select sales_stage from opportunity_master where sales_stage in ('Identified','QO_to be  approved') and assigned_user in (".$filter_username_string.") group by (sales_stage)");以下查詢?cè)?postgre 中正常運(yùn)行
查看完整描述

1 回答

?
白豬掌柜的

TA貢獻(xiàn)1893條經(jīng)驗(yàn) 獲得超10個(gè)贊

在開(kāi)始之前,我假設(shè)你了解laravel Eloquent

假設(shè)您的lead_master 表是LeadMaster Model,也是MeetingsMasterandOpportunityMaster


$lead_master = LeadMaster::select("lead_master.lead_stage as stage")

? ? ->join('user_master','user_master.user_name','=','lead_master.assigned_user_name')

? ? ->whereIn('region',$geo) //$geo is an array

? ? ->whereIn('teams',$filter_username) //also an array

? ? ->groupBy('lead_stage');


$meetings_master = MeetingsMaster::select('meeting_hash as stage')

? ? ->whereIn('assigned_user_name',$filter_username)

? ? ->whereIn('meeting_hash',['follow_up','first_time'])

? ? ->groupBy('meeting_hash');


$opportunity_master = OpportunityMaster::select('sales_stage as stage')

? ? ->whereIn('sales_stage',['Identified','QO_to be approved'])

? ? ->whereIn('assigned_user',filter_username)

? ? ->groupBy('sales_stage');


$query = $lead_master->union($meetings_master)->union($opportunity_master)->pluck('stage'); //your result

dd($query);

這就是你使用Laravel Eloquent時(shí)的樣子


ps:你不需要為此制作3個(gè)變量,我只是用它來(lái)方便維護(hù)


查看完整回答
反對(duì) 回復(fù) 2023-05-12
  • 1 回答
  • 0 關(guān)注
  • 137 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)