2 years ago

Join Statement using Query builder

Posted 2 years ago by bobmyles

Hi there,

I have a Query builder statement below and I would want to introduce another condition to the query. However, I can not get this right.

This query works fine;

$content = DB::table('subscribed_services as a')
                ->join('scheduled_messages as b', '', '=', 'b.subscribed_services_id')
                ->join('subscription_services_msisdn as c', '', '=', 'c.subscribed_services_id')
                ->whereRaw('DATE(b.scheduled_at) = CURDATE()')
                ->selectRaw('b.message, c. phone_number, a.username, a.password')

I would want to introduce another where statement; this ->whereRaw('DATE(c.sent_time) != CURDATE()'). Meaning the query above should only pick values where subscription_services_msisdn.sent_time DATE(c.sent_time) IS NOT EQUAL to Current Date CURDATE().

Anyone lead me here. Regards.

Please sign in or create an account to participate in this conversation.