From 0a4eee323b780769d9447f146bc06ec3a4ad6d8b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 27 Jun 2016 10:26:52 -0400 Subject: [PATCH] Use a subquery instead of a join to fix group by errors when sql_mode=only_full_group_by --- src/zm_event.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index fe9081436..e9ed27245 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -774,7 +774,7 @@ bool EventStream::loadInitialEventData( int init_event_id, unsigned int init_fra bool EventStream::loadEventData( int event_id ) { static char sql[ZM_SQL_MED_BUFSIZ]; - snprintf( sql, sizeof(sql), "select M.Id, M.Name, E.StorageId, E.Frames, unix_timestamp( StartTime ) as StartTimestamp, max(F.Delta)-min(F.Delta) as Duration,E.DefaultVideo from Events as E inner join Monitors as M on E.MonitorId = M.Id inner join Frames as F on E.Id = F.EventId where E.Id = %d group by E.Id", event_id ); + snprintf( sql, sizeof(sql), "select M.Id, M.Name, E.StorageId, E.Frames, unix_timestamp( StartTime ) as StartTimestamp, (SELECT max(Delta)-min(Delta) FROM Frames WHERE EventId=E.Id) as Duration,E.DefaultVideo from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = %d", event_id ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't run query: %s", mysql_error( &dbconn ) );