liomon41 Posted June 18, 2012 Share Posted June 18, 2012 Can anyone please explain to me in details(if possible) what this query does.. $query = "SELECT firstTeam, secondTeam, gameId, date, time, IF(SUBTIME(TIMESTAMP(`date`, `time`), '1:0:0') > NOW(), 1, 0) as active FROM fixtures ORDER BY date, time"; having issues with "as active" , never used that before, need your help... thanks Link to comment https://forums.phpfreaks.com/topic/264407-help-explain-this-query/ Share on other sites More sharing options...
smoseley Posted June 18, 2012 Share Posted June 18, 2012 "active" means the game hasn't started yet, and won't start within the next hour. Link to comment https://forums.phpfreaks.com/topic/264407-help-explain-this-query/#findComment-1354998 Share on other sites More sharing options...
liomon41 Posted June 19, 2012 Author Share Posted June 19, 2012 okay ... what about this part of the query ... IF(SUBTIME(TIMESTAMP(`date`, `time`), '1:0:0') > NOW(), 1, 0) Link to comment https://forums.phpfreaks.com/topic/264407-help-explain-this-query/#findComment-1355001 Share on other sites More sharing options...
smoseley Posted June 19, 2012 Share Posted June 19, 2012 It's exactly what I just said. That means "if date & time of the game is more than one hour in the future, return 1... otherwise return 0..." and that formula is aliased "AS" the pseudo-column "active". Link to comment https://forums.phpfreaks.com/topic/264407-help-explain-this-query/#findComment-1355014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.