mercredi 30 mai 2018

laravel select join and where clause

I'm learning Laravel framework in parallel developing a small project using it.

Below is the mysql query which I'm trying to incorporate

select id from emails where id not in (select distinct(e.id) from allbreaches b join breaches br on b.domain_name = br.domain_name join emails e on br.eid = e.id where b.domain_name in ("example.com","sample.com");

I'm wondering what is wrong in the below laravel query?

$domainNameList = array('example.com','sample.com');
            $idList = DB::table('emails')
                ->whereNotIn('id', function ($query) {
                    $query->DB::table('allbreaches')
                        ->join('breaches', 'breaches.domain_name', '=', 'allbreaches.domain_name')
                        ->join('emails', 'breaches.eid', '=', 'emails.id')
                        ->whereIn('breaches.domain_name', $domainNameList)
                        ->distinct()->get(['emails.id']);
                })
                ->get();



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2L8TjI6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire