gpt4 book ai didi

mysql - 归类与嵌套选择的非法混合

转载 作者:行者123 更新时间:2023-11-29 02:29:18 25 4
gpt4 key购买 nike

我有一个 MySQL 查询,其中包含一些嵌套选择。如下:

我的内部查询,返回两列:

     ` MIN( PreQuery.updatetime ) as InTime`

`MAX( PreQuery.updatetime ) as OutTime`

这些是日期时间格式,2013-03-22 12:04:06

我只想返回过去 26 小时内的日期时间,因此请使用 where 子句:'InTime'> DATE_SUB(NOW(), INTERVAL 26 HOUR)

返回错误:#1267 - 操作 '>' 的排序规则 (utf8_general_ci,COERCIBLE) 和 (latin1_swedish_ci,NUMERIC) 的非法混合

关于如何更正此问题或仅显示过去 26 小时的数据有什么想法吗?一如既往的感谢。

select * from (select
PreQuery.callingname,
PreQuery.geofence,
PreQuery.GroupSeq,
MIN( PreQuery.`updatetime` ) as InTime,
MAX( PreQuery.`updatetime` ) as OutTime
from
( select
v_starting.callingname,
v_starting.geofence,
v_starting.`updatetime`,
@lastGroup := @lastGroup + if( @lastAddress = v_starting.geofence
AND @lastVehicle = v_starting.callingname, 0, 1 ) as GroupSeq,
@lastVehicle := v_starting.callingname as justVarVehicleChange,
@lastAddress := v_starting.geofence as justVarAddressChange
from
v_starting,
( select @lastVehicle := '',
@lastAddress := '',
@lastGroup := 0 ) SQLVars
order by
v_starting.`updatetime` ) PreQuery
Group By
PreQuery.callingname,
PreQuery.geofence,
PreQuery.GroupSeq) parent

where geofence <>'' and 'InTime'> DATE_SUB(NOW(), INTERVAL 26 HOUR)

最佳答案

去掉InTime两边的撇号,即

where geofence <>'' and InTime >  DATE_SUB(NOW(), INTERVAL 26 HOUR)

关于mysql - 归类与嵌套选择的非法混合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15571579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com