添加另一个条件过程

adding another condition procedure

这是我的程序..

我怎样才能添加另一个条件来满足 driver_latlong table 中的 updated_time 记录应该少于 1 分钟??

这是我的程序

BEGIN
SET @sql = CONCAT(
    'SELECT (DriverLocation.updated_at - NOW()) as Diff, DriverLocation.updated_at,  NOW(), DriverLocation.AutoId, DriverLocation.DriverId,  
    @dist:= ( 6371 * acos( cos( radians(',lat,') ) * cos( radians( DriverLocation.Lat ) ) * cos( radians( DriverLocation.Long ) - radians(',lng,') ) + sin( radians(',lat,') ) * sin( radians( DriverLocation.Lat ) ) ) ) AS distance 
    FROM driver_latlong DriverLocation LEFT JOIN driver_details DriverDetail on DriverDetail.DriverId = DriverLocation.DriverId where DriverLocation.DriverId NOT IN (',Exclude,') AND DriverDetail.IsActive=',1,' AND DriverDetail.IsOnline=',1,'   having distance <=50000.0 ORDER BY distance ASC LIMIT 0 , 1;');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END

如果您只参考 MySQL 得到的时间,即 NOW()

您将获得具有 0 到 60 秒(1 分钟)之间差异的记录

然后您应该将其添加到您的程序中

AND (DriverLocation.updated_at - NOW() BETWEEN  0 AND 60 )