Raw Query in Laravel

We can write raw query in laravel as shown below. Here we have made use of where, where in, with ‘and’ and ‘or’ condition. The most important thing you need to consider while writing raw query is DB::select( DB::raw())


  $vehicleHistoryDetail =
            DB::select( DB::raw("SELECT mdi_ext_batt_voltage,mdi_dashboard_fuel_level,mdi_obd_mileage FROM vehicle_info_devices WHERE profile_id IN (1,2)and(
        mdi_dashboard_fuel_level <> 0 or mdi_ext_batt_voltage <> 0 or mdi_obd_mileage <> 0) ") );

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s