I'm working with my php project that needs to display a photo from "Profile Pictures" album in facebook.
The algorithm is to get the photo with highest likes during (2011,2012,2013,2015). I already have query here but it doesn't have the range and filtering here. This query only displays ALL the photos in "Profile Pictures" album with sorting it by the number of likes.
The only problem is that it only displays one result (From year 2013 photo with highest likes).
What I want is to limit 1 result from year 2011-2015 the photo with highest likes.
Here is my query:
SELECT src_big, created, like_info.like_count
FROM photo
WHERE album_object_id IN (
SELECT object_id
FROM album
WHERE owner = me()
AND type='profile'
) AND created > strtotime("JANUARY 1 2012") AND created < strtotime("DECEMBER 30 2013") ORDER by like_info.like_count desc LIMIT 1
Result
{
"data": [
{
"src_big": "https://scontent.xx.fbcdn.net/hphotos-xpf1/v/t1.0-9/.jpg?oh=&oe=56CBED89",
"created": 1383733734,
"like_info": {
"like_count": 330
}
}
],
}