$employee=DB::table('gb_employee as e')
->select('e.*')
->leftJoin('gb_emp_client_lines as el', 'e.employee_id', '=', 'el.gb_emp_client_empid')
->whereNull('el.gb_emp_client_empid',)
->get()
;
口才
class Employee extends Model
{
public function client_lines()
{
return $this->hasMany('App\ClientLines', 'gb_emp_client_empid', 'employee_id');
}
}
$employees = Employee::doesntHave('client_lines')->get();
2条答案
按热度按时间x759pob21#
我想我解决了。
oxf4rvwz2#
为此使用左连接
口才