laravel不在哪里

时间:2017-11-22 19:25:53

标签: laravel-5 laravel-5.2 laravel-5.1 laravel-5.3

这是我的mysql代码

SELECT name,lastname FROM employee WHERE employee.id_employee
NOT IN (SELECT assistancea.id_employee FROM assistance WHERE assistance.id_meeting=3)

我在等待3号的值 3是会议的id_meeting

table employe  
|id_employe|name|lastname

table assistance  
|id_employe|id_meetign|

table meeting  
|id_metting|description|date

你可以帮我从laravel进行查询

1 个答案:

答案 0 :(得分:0)

我是为你写的。

DB::table('employee AS employee')
    ->select(['employee.name','employee.lastname'])
    ->whereNotExists(function ($query) {
            $query->select(DB::raw(1))
                ->from('assistance AS assistance')                      
                ->where('assistance.id_meeting','=',3)                      
                ->whereRaw('employee.id_meeting = assistance.id_meeting');
        })->get();