我有一个返回正确数据的查询,除了左连接没有返回最新记录(按 dateuploaded 列排序) 感谢您的帮助。
select a.*,p.thumbnailphotopath as Picture from album_access ac
inner join albums a on a.ID = ac.AlbumID
left join (select albumid, thumbnailphotopath,max(DateUploaded) from photos where IsProcessed = 1 and IsPrivate = 0 GROUP BY albumID) p on a.ID = p.AlbumID #photos record not latest
where ac.AccessUserID = ? and ac.Ispending = 0 and ac.FullControl = 1 and a.Private = 1 order by a.DateCreated desc limit ?,?;
List of dates that return desc (its returning 2012-05-01 09:45:43 and thats not the latest)
2012-05-01 09:46:17
2012-05-01 09:46:06
2012-05-01 09:45:43 --Returning this record
2012-05-01 09:45:30
2012-05-01 09:39:49