0
SELECT  WorkerId, MAX(  `TimeStamp` ) AS TimeStamp,  `Latitude` ,  `Longitude`
FROM  `workers_actions` 
JOIN worker_user w ON WorkerId = w.Id
WHERE  `ScannedTimestamp` >= DATE( NOW( ) ) 
        AND FarmerId=:farmer_id
        AND Longitude is not null 
        AND Longitude != 0 
        AND Latitude is not null 
        AND Latitude != 0 
GROUP BY WorkerId

Will i be getting Latitude and Longitude of the row with max timestamp or Is it not garaunteed?

Strawberry
  • 33,750
  • 13
  • 40
  • 57
Ofek Ron
  • 8,354
  • 13
  • 55
  • 103
  • If you have selected the column, of course it will appear in the returned results. However, having any rows that match your criteria is another issue. – Terry Nov 09 '16 at 09:53
  • 2
    Short answer: no. For long answer see the duplicate topic. – Shadow Nov 09 '16 at 10:01
  • https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html - _If ONLY_FULL_GROUP_BY is disabled, a MySQL extension to the standard SQL use of GROUP BY permits the select list, HAVING condition, or ORDER BY list to refer to nonaggregated columns even if the columns are not functionally dependent on GROUP BY columns. This causes MySQL to accept the preceding query. In this case, the server is free to choose any value from each group, so unless they are the same, the values chosen are indeterminate_ – Kickstart Nov 09 '16 at 10:45

0 Answers0