How to use the Where in the consultation in laravel

0

How can I make a query below with mysql in laravel:

SELECT
    gps.positions.id,
    gps.positions.protocol,
    gps.positions.deviceid,
    gps.positions.servertime,
    gps.positions.devicetime,
    gps.positions.fixtime,
    gps.positions.valid,
    gps.positions.latitude,
    gps.positions.longitude,
    gps.positions.altitude,
    gps.positions.speed,
    gps.positions.course,
    gps.positions.address,
    gps.positions.attributes,
    gps.positions.accuracy,
    gps.positions.network,
    sing.veiculos.identificacao,
    sing.veiculos.id_tipo,
    sing.veiculos.descricao,
    sing.veiculos.deviceid
FROM gps.positions
LEFT JOIN sing.veiculos ON sing.veiculos.deviceid = gps.positions.id
WHERE gps.positions.devicetime IN ((SELECT MAX(devicetime) FROM positions GROUP BY deviceid));

Thank you in advance and I'm waiting for a light.

    
asked by anonymous 21.03.2018 / 17:46

1 answer

0

It's another, seemingly simpler way to do what you want:

$dados = DB::table('tabela')->whereIn('id', [1, 2, 3])->get();

For more information: link

    
24.12.2018 / 15:58