我有一个具有以下字段的表用户。
id user_name team onsite_offshore
1 xxx US East offshore
2 YYY US East onsite
3 zzz US East onsite
4 aaa Us West onsite
5 bbb US West offshore我有两个依赖的下拉地理和地理位置,地理值'US East‘和'US West’,位置值'US East‘和’US East‘的前提是’US East‘
“美国西部和前提”的意思是“美国西部”。
地质定位
美国东部-美国东部,近海(逐个显示为2个选项),美国西部-美国西部和近海(逐个显示为2个选项)
on choosing US East in localtion with geo 'US East' dropdow I want to load the value 'yyy,zzz' which is not inluded in offshore(which is in same table with different column.)
on choosing offshore in localtion dropdown for geo 'US EASt'I want to load the value 'XXX' which is should inluded in offshore(which is in same table with different column.)
on choosing US West in localtion with geo 'US West' dropdown I want to load the value 'aaa' which is not inluded in offshore(which is in same table with different column.)
on choosing offshore in localtion dropdown for geo 'US West' I want to load the value 'bbb' which is should inluded in offshore(which is in same table with different column.)
$filter_team_details=DB::table('user_master')->leftjoin('user_teams','user_teams.team','=','user_master.geo')->whereIn('user_teams.team',$teams)->groupBy('user_teams.team')->pluck('user_teams.team')->toArray(); (In this query I want to check for onsite_offshore condition in same query )是否可以将两个条件单表检查为
发布于 2020-06-02 11:05:36
我不知道为什么要使用whereIn,您的查询可以这样简单地为多个条件编写:
$filter_team_details = DB::table('user_master')
->leftjoin('user_teams','user_teams.team','=','user_master.geo')
->where('user_teams.team',$teams)
->where('user_teams.onsite_offshore',$nameOfyourVariable)
->groupBy('user_teams.team')
->pluck('user_teams.team')
->toArray();尽管您可以使用whereIn (如果您愿意,我希望它对您有帮助:)
https://stackoverflow.com/questions/62149175
复制相似问题