【问题标题】:adding another condition procedure添加另一个条件过程
【发布时间】:2015-02-17 18:55:13
【问题描述】:

这是我的程序..

我怎样才能添加另一个条件,它应该满足 driver_latlong 表中的 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

【问题讨论】:

    标签: php mysql stored-procedures procedure


    【解决方案1】:

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

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

    然后你应该把它添加到你的程序中

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-21
      • 2011-09-24
      • 2021-11-01
      • 2022-11-03
      • 2016-07-20
      • 1970-01-01
      • 2017-12-26
      • 1970-01-01
      相关资源
      最近更新 更多