Eloquent normal sql select statement

1001 0 0 0

Last Updated : 2024-04-24 03:32:20

In laravel and eloquent, some times you might need to run a normal SQL select statement. So here is an example to do so:

use DB;

$qq = "
SELECT
committeesmeetings.*,
committeeevidences.dateTimestamp,
committeeevidences.speakerTitle,
committeeevidences.speakerName,
committeeevidences.InstitutionDebate,
committees.acronym as committee_acronym,
committees.name as committee_name

FROM
committees,committeesmeetings,committeeevidences,favorites
WHERE
committeesmeetings.dateText = '$theNewDateInDateText' AND
committeesmeetings.meetingNo = committeeevidences.meetingNo AND
committeesmeetings.id = committeeevidences.meeting_id AND
committeesmeetings.committee_id = favorites.bill_id AND
favorites.entity_type = 'committee' AND
favorites.user_id = $loggedInUserId AND
committeesmeetings.committee_id = committees.id

Group by committeesmeetings.meetingNo
ORDER BY
committeesmeetings.id ASC
LIMIT 500
";
$allFavoredCommitteesRecords = DB::select( $qq );

Mohammed Anwar

Mohammed Anwar

Experienced technical lead PHP, MySQL and Laravel Developer for 15+ years, with proven ability to develop and create high-quality and optimized web applications. Great ability to build and optimize database design, schema and queries. Versed programing trainer and instructor delivering web courses and helping others to get into the field in a timely manner. Fast and eager learner for new technologies .